-
-
Save skarllot/c1b6abd379d863b80062 to your computer and use it in GitHub Desktop.
Linux device rescan/resize after virtual machine changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: http://blog.gurudelleccelsopicco.org/2009/09/online-lun-expansion-and-partition-resizing-without-reboot-under-linux/ | |
echo 1 > /sys/block/[DEVICE]/device/rescan | |
# DETECT IF NEW DISKS ARE ATTACHED TO THE HOST | |
# Reference: http://www.cyberciti.biz/tips/vmware-add-a-new-hard-disk-without-rebooting-guest.html | |
ls /sys/class/scsi_host | |
# Output: | |
# host0 host1 ... | |
# Now type the following to send a rescan request: | |
echo "- - -" > /sys/class/scsi_host/host0/scan | |
fdisk -l | |
# OR | |
ls /sys/class/scsi_host/ | while read host ; do echo "- - -" > /sys/class/scsi_host/$host/scan ; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parted /dev/sdX | |
(parted) unit s | |
(parted) print | |
# copy start value | |
(parted) rm ? | |
(parted) mkpart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lsof +D /mnt/part | |
lsof | grep '/dev/sdX' | |
fuser -vm /mnt/part | |
swapon -s | |
umount /mnt/part |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment