Repartitioning modern Linux systems without reboot
This one is for my own future reference as much as anything. Ever since the move to udev in Linux 2.6, I’ve found it neccesary to do the very un-Linux like thing of rebooting before the appropriate device appeared under /dev. This was only an occasional hassle but still, you shouldn’t need to reboot Linux for such a thing.
Thanks to Robert for his Google magic in turning up partprobe, part of the GNU Parted package. As the Debian man page for partprobe says
partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.
Excellent! Parted is normally installed on Debian and Ubuntu by default anyways, if not, simply, aptitude install parted and you’ll have access to the excellent partprobe.
We were trying to add some additional swap to a running system, the full series of commands needed as follows (I could have used parted to create the partition but the cfdisk tool has a nice interface),
- sudo cfdisk /dev/sda (and create new partition of type FD, Linux RAID)
- sudo cfdisk /dev/sdb (and create new partition of type FD, Linux RAID)
- sudo partprobe
- sudo mdadm –create /dev/md3 -n 2 -x 0 -l 1 /dev/sda4 /dev/sdb4 (our swap devices are software RAID1 devices)
- sudo /etc/init.d/udev restart (this updates /dev/disk/by-uuid/ with the new RAID device)
- sudo mkswap /dev/md3
- sudo vi /etc/fstab (and add a new entry for /dev/md3 as a swap device)
- sudo swapon -a (to activate the swap device)
- sudo swapon -s (to verify it is working)
No comments yet.