Difference between revisions of "Adding a Disk and Extending a Logical Volume"
From Peter Pap's Technowiki
Line 32: | Line 32: | ||
3. Check to see if the new device is there | 3. Check to see if the new device is there | ||
− | # | + | # ls -al /dev/sd* |
− | + | brw-rw---- 1 root disk 8, 0 Jan 22 01:14 /dev/sda | |
− | + | brw-rw---- 1 root disk 8, 1 Jan 22 01:14 /dev/sda1 | |
− | + | brw-rw---- 1 root disk 8, 2 Jan 22 01:14 /dev/sda2 | |
− | + | brw-rw---- 1 root disk 8, 3 Jan 22 01:14 /dev/sda3 | |
− | + | brw-rw---- 1 root disk 8, 16 Jan 22 01:14 /dev/sdb | |
+ | brw-rw---- 1 root disk 8, 17 Jan 22 01:14 /dev/sdb1 | ||
+ | brw-rw---- 1 root disk 8, 32 Jan 22 01:14 /dev/sdc | ||
+ | brw-rw---- 1 root disk 8, 33 Jan 22 01:14 /dev/sdc1 | ||
+ | '''brw-rw---- 1 root disk 8, 48 Jan 22 01:14 /dev/sdd''' | ||
+ | |||
+ | 4. Add the disk to your machine as a primary partition | ||
+ | |||
+ | # fdisk /dev/sdd | ||
+ | Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel | ||
+ | Building a new DOS disklabel with disk identifier 0x663d32f6. | ||
+ | Changes will remain in memory only, until you decide to write them. | ||
+ | After that, of course, the previous content won't be recoverable. | ||
+ | |||
+ | Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) | ||
+ | |||
+ | WARNING: DOS-compatible mode is deprecated. It's strongly recommended to | ||
+ | switch off the mode (command 'c') and change display units to | ||
+ | sectors (command 'u'). | ||
+ | |||
+ | Command (m for help): '''m''' | ||
+ | Command action | ||
+ | a toggle a bootable flag | ||
+ | b edit bsd disklabel | ||
+ | c toggle the dos compatibility flag | ||
+ | d delete a partition | ||
+ | l list known partition types | ||
+ | m print this menu | ||
+ | n add a new partition | ||
+ | o create a new empty DOS partition table | ||
+ | p print the partition table | ||
+ | q quit without saving changes | ||
+ | s create a new empty Sun disklabel | ||
+ | t change a partition's system id | ||
+ | u change display/entry units | ||
+ | v verify the partition table | ||
+ | w write table to disk and exit | ||
+ | x extra functionality (experts only) | ||
+ | |||
+ | Command (m for help): '''n''' | ||
+ | Command action | ||
+ | e extended | ||
+ | p primary partition (1-4) | ||
+ | '''p''' | ||
+ | Partition number (1-4): '''1''' | ||
+ | First cylinder (1-13054, default 1): | ||
+ | Using default value 1 | ||
+ | Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054): | ||
+ | Using default value 13054 | ||
+ | |||
+ | Command (m for help): '''w''' | ||
+ | The partition table has been altered! | ||
+ | |||
+ | Calling ioctl() to re-read partition table. | ||
+ | Syncing disks. | ||
+ | |||
+ | You sould now have an additional device: | ||
# ls -al /dev/sd* | # ls -al /dev/sd* | ||
Line 48: | Line 104: | ||
brw-rw---- 1 root disk 8, 32 Jan 22 01:14 /dev/sdc | brw-rw---- 1 root disk 8, 32 Jan 22 01:14 /dev/sdc | ||
brw-rw---- 1 root disk 8, 33 Jan 22 01:14 /dev/sdc1 | brw-rw---- 1 root disk 8, 33 Jan 22 01:14 /dev/sdc1 | ||
− | '''brw-rw---- 1 root disk 8, | + | brw-rw---- 1 root disk 8, 48 Jan 22 01:14 /dev/sdd |
+ | '''brw-rw---- 1 root disk 8, 49 Jan 22 01:14 /dev/sdd1''' |
Revision as of 03:31, 22 January 2015
So you have a logical volume that has run out of space and you need to add more. Either it's a VM and you've added another disk file or it's a physical server and you've added another disk.
1. Check the current disk devices with the following commands:
# pvscan PV /dev/sdb1 VG data lvm2 [100.00 GiB / 0 free] PV /dev/sdc1 VG data lvm2 [100.00 GiB / 0 free] PV /dev/sda3 VG vg1 lvm2 [47.84 GiB / 17.59 GiB free] Total: 4 [247.83 GiB] / in use: 3 [247.83 GiB] / in no VG: 0 [0 ] # ls -al /dev/sd* brw-rw---- 1 root disk 8, 0 Jan 22 01:14 /dev/sda brw-rw---- 1 root disk 8, 1 Jan 22 01:14 /dev/sda1 brw-rw---- 1 root disk 8, 2 Jan 22 01:14 /dev/sda2 brw-rw---- 1 root disk 8, 3 Jan 22 01:14 /dev/sda3 brw-rw---- 1 root disk 8, 16 Jan 22 01:14 /dev/sdb brw-rw---- 1 root disk 8, 17 Jan 22 01:14 /dev/sdb1 brw-rw---- 1 root disk 8, 32 Jan 22 01:14 /dev/sdc brw-rw---- 1 root disk 8, 33 Jan 22 01:14 /dev/sdc1
2. Scan the scsi bus to find the new disk
List the host SCSI adapters
# ls /sys/class/scsi_host/ host0 host1 host2
Probe each host adapter
# echo "- - -" > /sys/class/scsi_host/host0/scan # echo "- - -" > /sys/class/scsi_host/host1/scan # echo "- - -" > /sys/class/scsi_host/host2/scan
3. Check to see if the new device is there
# ls -al /dev/sd* brw-rw---- 1 root disk 8, 0 Jan 22 01:14 /dev/sda brw-rw---- 1 root disk 8, 1 Jan 22 01:14 /dev/sda1 brw-rw---- 1 root disk 8, 2 Jan 22 01:14 /dev/sda2 brw-rw---- 1 root disk 8, 3 Jan 22 01:14 /dev/sda3 brw-rw---- 1 root disk 8, 16 Jan 22 01:14 /dev/sdb brw-rw---- 1 root disk 8, 17 Jan 22 01:14 /dev/sdb1 brw-rw---- 1 root disk 8, 32 Jan 22 01:14 /dev/sdc brw-rw---- 1 root disk 8, 33 Jan 22 01:14 /dev/sdc1 brw-rw---- 1 root disk 8, 48 Jan 22 01:14 /dev/sdd
4. Add the disk to your machine as a primary partition
# fdisk /dev/sdd Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x663d32f6. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-13054, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054): Using default value 13054 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
You sould now have an additional device:
# ls -al /dev/sd* brw-rw---- 1 root disk 8, 0 Jan 22 01:14 /dev/sda brw-rw---- 1 root disk 8, 1 Jan 22 01:14 /dev/sda1 brw-rw---- 1 root disk 8, 2 Jan 22 01:14 /dev/sda2 brw-rw---- 1 root disk 8, 3 Jan 22 01:14 /dev/sda3 brw-rw---- 1 root disk 8, 16 Jan 22 01:14 /dev/sdb brw-rw---- 1 root disk 8, 17 Jan 22 01:14 /dev/sdb1 brw-rw---- 1 root disk 8, 32 Jan 22 01:14 /dev/sdc brw-rw---- 1 root disk 8, 33 Jan 22 01:14 /dev/sdc1 brw-rw---- 1 root disk 8, 48 Jan 22 01:14 /dev/sdd brw-rw---- 1 root disk 8, 49 Jan 22 01:14 /dev/sdd1