Changing a disk with partitions on it.

The disk has partitions on it for swap, /var, /tmp and one I have called /home2 and I want to change it for a larger disk. I can see how to do this by forgetting home2 which is backed up anyway and then creating partitions some where else for swap var and temp. Changing fstab to suite, changing the disk, partitioning it to suite assuming yast will allow me to set a swap partition on it and then another fstab and reboot.

It struck me that I could prepare the disk and only change fstab once. The only way I can do that is to plug it into a usb dock and use YAST. However I then have a disk that’s ready but have no idea what I need to put in fstab to cause the partitions on it to mount correctly as I don’t know how it will be identified when it does reboot.

Is there some way around that problem - that I don’t know how it will be identified. It comes up as this in yast - /dev/sdn prolific -atapi-6 bridge C.when in the dock. It’s a western digital disk.

John

That’s probably a reference to hardware in the dock. I have an external drive like that, and it gives me problems.

Safest would be to identify partitions by the UUID of their file systems. You can use the “blkid” command (while the drive is plugged in) to find the UUIDs.

In addition to changing “fstab”, you will probably need to reinstall “grub2” and to rebuild the “initrd”.

Thanks. Looking at this has made me wonder how the uuid’s are obtained ? Anyone know?

I wont need to do anything with grub. The disk is the one with swap etc on it. I worries me… Over 300,000,000 read errors all corrected with parity so no recorded real read errors. It’s what hp supplied in a workstation.


john@dhcppc0:~> cat /etc/fstab
/dev/disk/by-id/ata-PLEXTOR_PX-128M5Pro_P02306101219-part2      /       ext4    acl,user_xattr 1 1 
/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part1  swap    swap    defaults 0 0 
/dev/disk/by-id/ata-PLEXTOR_PX-128M5Pro_P02306101219-part1      /boot/efi       vfat    umask=0002,utf8=true 0 0 
/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part4  /home/home2     ext4    noacl,user_xattr 1 2 
/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part3  /tmp    ext4    acl,user_xattr 1 2 
/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part2  /var    ext4    acl,user_xattr 1 2 
/dev/md0             /home               ext4       acl,user_xattr        1 2


I’ve had no problems at all that I’m aware of with the usb dock. It has a good card reader in it too. I’ve used it for back up and restore several times. :expressionless: However it’s a new usb3 one so hope it’s as good as the one it’s replaced.

John

UUID ar random strings generated at the time of partition creation and stored at the beginning of the partition.

You will need to do something with grub. Look in “/etc/default/grub”. There is likely to be a reference to your swap partition (with “resume=”). Update that, and then regenerate “grub.cfg” with

grub-mkconfig -o /boot/grub2/grub.cfg

I’m not sure if information about swap is stored in the “initrd”.

Not swap, but resume device (they are not necessary the same, although usually nobody allocates partition for resume only). Information about resume is stored in initrd, and can be overridden by kernel command line.

:’(I’d forgotten resume as I don’t use it so assumed swap would be easy to add to a new disk when I initially settled on the partitioning. :slight_smile: However looks like swap is painful where ever it is. Currently grub has


GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/disk/by-id/ata-VB0250EAVER_Z3TCNPGW-part1 splash=silent quiet showopts"
GRUB_CMDLINE_LINUX=""

Disk by-id probably wont be of any use any more as there are 2 other identically id’d disks in the raid array. I assume that can be disk/by-uuid or maybe disk by-parrtlable etc ? Same for fstab and that can have mixed id methods? I’m pretty sure I have had fstabs like that in the past but best to be sure. To be honest I would prefer labels, ideally by partition so that if something does need changing it’s easier to know which one is which.

My usual way of doing this sort of thing is to create separate config files so that if faced with linux’s vastly superior blue screen of death I can easily put things back where they were and have another go etc. That looks to be reasonable as far as grub is concerned, just need to note the command to restore to the original configuration.

I only have a rough idea of how linux boots but do wonder why initrd needs swap. Resume I would have thought goes back to exactly as things were before and can also be into ram rather than disk. Initrd is a single file so maybe I can create a new one and retain the old and copy over if things go wrong. I suspect it’s not as simple as that though ? Also knowing that it can be done from the command line doesn’t tell anyone how.

Maybe there is a way of telling linux not to use swap during boot - no resume in other words so that the grub line can be commented out and another one added ? :wink: That sounds favourite to me. Sort that out later when the final set up is working.

There also seems to be a problem getting to a shell straight from boot. I did want to do that when I sorted out my /home but couldn’t find any way of doing it. It wouldn’t be a bad idea to have that option in the boot menu really for numpties like me.

John

A web search bought this up. I thought it might for the reason it gives

                 For reasons I have long ago forgotten, I commented out the resume  device line for my file server and most of my workstations.  Something  about making it easier to clone drives to make new systems while  removing/moving around partitions in the new systems.

I never suffered any ill consequences from this. I didn’t remove uswsusp, I just commented out the resume device line. As far as I know, this leaves uswsusp as nothing more than dead weight in my systems; I can’t imagine it has any useful functionality without any device to “do stuff” with.

True or false ?? I assume the commented out line is in the grub configuration line I posted. However it might not be. The uswsusp comment is down to the thread. It didn’t work on a swap file that contained an encrypted partition so that had to be removed and then all was ok.

Once fstab comes into play swap will be defined.

John

Resume is needed only if you hibernate

The previous quote may be distro dependent so I really need to know how opensuse functions in this respect. Another quote from a debian based one

                    ben  - uuid changes are not always reflected until after a reboot...

follow THESE instructions and report back
1, determine your swap with ‘fdisk -l’
2, do mkswap on your swap partition - RECORD THE UUID WHICH THIS COMMAND
OUTPUTS
3, now use this UUID to put into fstab and resume
files…(RESUME=UUID=<the-swap-partition-uuid-from-vol_ID
should go in /etc/initramfs-tools/conf.d/resume
4, update-initramfs -u
5, reboot normally after this finishes
when the system has restarted again - do ‘swapon -s’ to check if your
swap is active…and do ‘ls -la /dev/disk/by-uuid/’
dont change any symlinks etc. just try these instructions

Opensuse uses different tools. Centos has a kernel panic if it can’t find swap during boot so the crux of the matter initially is if commenting out the grub part automatically tells initrd not to bother with it as per the quote in my other post.

John

Maybe I needed this person to read the thread. If correct it is worth adding to this thread

Now, that was a real convoluted method of doing this! I am surprised Miuku and gogalthorp missed it.

All you needed to do was launch the Yast Partitioner. Choosing the Swap partition, you merely then had a choice to Edit, Move, Resize, or Delete.

Quick, straight-forward, simple…

My favourite method is to Edit, where I choose the Do Not Mount option, then Finish out of the Partitioner. This turns off the Swap file and removes it from fstab, taking care of the fine details as it goes.

Then, back into the Partitioner, create a new Swap partition on the other drive, select to mount that partition, and it creates, adds to fstab, and starts the Swap in the new location.

No problems with Grub, no other problems, done, fully system aware, and over with.-Gerry Makaro
Fraser-Bell Info Tech
*
Solving Tech Mysteries since the Olden Days!
***~~~~~
If I helped you, consider clicking the Star at the bottom left of my post.

I would need to reboot though to change the drive over. I believe that all distro’s can in principle run without swap and in my case I don’t think it’s ever used so could I use this method to remove the current swap completely. Power down, fit a prepared disk, boot up and then mount swap on the new disk via yast ?

:expressionless: I can’t afford the time to break my machine. My wife wants me back on stripping the kitchen completely and refitting all new. I’m just getting rather pointed looks at the moment.

Otherwise it comes back to the question about commenting out the line in grub config preventing initrd from trying to find swap. Does that happen?

John

Well.

I’m posting this after using yast to set don’t mount swap and rebooting. I decided to try it as I am pretty sure that the kernel will chuck out things that are currently not in use when it runs out of memory. Memory usage with a console open plus a browser with 14 tabs is about 3.3gb. 1,1gb used for cache. Free shows 0,0,0 for swap so assume it shows it even if not there.

This shows what is mounted. Lot of lines and no swap


john@dhcppc0:~> cat /proc/mounts
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,nosuid,size=12297736k,nr_inodes=3074434,mode=755 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
/dev/sda2 / ext4 rw,relatime,data=ordered 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=22,pgrp=1,timeout=0,minproto=5,maxproto=5,direct 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
/dev/sda1 /boot/efi vfat rw,relatime,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/md0 /home ext4 rw,relatime,data=ordered 0 0
/dev/sdb4 /home/home2 ext4 rw,relatime,noacl,data=ordered 0 0
/dev/sdb2 /var ext4 rw,relatime,data=ordered 0 0
/dev/sdb3 /tmp ext4 rw,relatime,data=ordered 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
tmpfs /run/user/478 tmpfs rw,nosuid,nodev,relatime,size=2461676k,mode=700,uid=478,gid=476 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=2461676k,mode=700,uid=1000,gid=100 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0


Next step is to remount swap in YAST reboot and see that all comes back.

John

There was a problem rebooting after remounting swap but not down to that. :)I suspect it’s my other problem that I haven’t mentioned yet and due to that had to reboot via the power switch at the point when grub should kick in. That happened several times before changing anything. Mount is now


john@dhcppc0:~> cat /proc/mounts
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
devtmpfs /dev devtmpfs rw,nosuid,size=12297736k,nr_inodes=3074434,mode=755 0 0
securityfs /sys/kernel/security securityfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /dev/shm tmpfs rw,nosuid,nodev 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,nodev,mode=755 0 0
tmpfs /sys/fs/cgroup tmpfs ro,nosuid,nodev,noexec,mode=755 0 0
cgroup /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd 0 0
pstore /sys/fs/pstore pstore rw,nosuid,nodev,noexec,relatime 0 0
efivarfs /sys/firmware/efi/efivars efivarfs rw,nosuid,nodev,noexec,relatime 0 0
cgroup /sys/fs/cgroup/memory cgroup rw,nosuid,nodev,noexec,relatime,memory 0 0
cgroup /sys/fs/cgroup/cpu,cpuacct cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct 0 0
cgroup /sys/fs/cgroup/freezer cgroup rw,nosuid,nodev,noexec,relatime,freezer 0 0
cgroup /sys/fs/cgroup/perf_event cgroup rw,nosuid,nodev,noexec,relatime,perf_event 0 0
cgroup /sys/fs/cgroup/cpuset cgroup rw,nosuid,nodev,noexec,relatime,cpuset 0 0
cgroup /sys/fs/cgroup/blkio cgroup rw,nosuid,nodev,noexec,relatime,blkio 0 0
cgroup /sys/fs/cgroup/net_cls,net_prio cgroup rw,nosuid,nodev,noexec,relatime,net_cls,net_prio 0 0
cgroup /sys/fs/cgroup/hugetlb cgroup rw,nosuid,nodev,noexec,relatime,hugetlb 0 0
cgroup /sys/fs/cgroup/pids cgroup rw,nosuid,nodev,noexec,relatime,pids 0 0
cgroup /sys/fs/cgroup/devices cgroup rw,nosuid,nodev,noexec,relatime,devices 0 0
/dev/sda2 / ext4 rw,relatime,data=ordered 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=23,pgrp=1,timeout=0,minproto=5,maxproto=5,direct 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
/dev/sda1 /boot/efi vfat rw,relatime,fmask=0002,dmask=0002,allow_utime=0020,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0
/dev/md0 /home ext4 rw,relatime,data=ordered 0 0
/dev/sdb3 /tmp ext4 rw,relatime,data=ordered 0 0
/dev/sdb2 /var ext4 rw,relatime,data=ordered 0 0
/dev/sdb4 /home/home2 ext4 rw,relatime,noacl,data=ordered 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
tmpfs /run/user/478 tmpfs rw,nosuid,nodev,relatime,size=2461676k,mode=700,uid=478,gid=476 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=2461676k,mode=700,uid=1000,gid=100 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100 0 0
fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0


Still no sign of swap but now


             total       used       free     shared    buffers     cached                                                                                                                                                    
Mem:      24616732    2284676   22332056      23052     145736    1066720                                                                                                                                                    
-/+ buffers/cache:    1072220   23544512
Swap:     10481660          0   10481660


When I set swap unmounted with yast it decided to install reiserfs. Bad memories for me as the driver wrecked a disk following an update due to failing some unused disk space that was perfectly ok…

However should mount show that swap is mounted and what to do ?

John

:sarcastic:It seems that another method should be used to check swap is mounted


john@dhcppc0:~> cat /proc/swaps
Filename                                Type            Size    Used    Priority                                                                                                                                             
/dev/sdb1                               partition       10481660        0       -1                                                                                                                                           

Or at least that seems to be the case. Not at all sure what the -1 means.

John