- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: how to expand disk space on linux
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2008 04:01 PM
тАО10-13-2008 04:01 PM
I'm very new to Linux. We have a drive on our linux box that is nfs mounted to the hp boxes. the drive is getting full and since there was not a volume group created on it, need to know if there is a way to expand it at this poing could we create a volume group and add that disk to it at this time?
here is the information I get on the system:
pvdisplay -v /dev/sda1
Using physical volume(s) on command line
No physical volume label read from /dev/sda1
Failed to read physical volume "/dev/sda1"
/dev/sda1 258033560 229383152 15542980 94% /vol
your help is very much appreciated since this is becoming an urgent situation.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2008 10:01 PM
тАО10-13-2008 10:01 PM
Re: how to expand disk space on linux
You have only one disk and that is full.
add one more disk and create
1. physical volume:
pvcreate /dev/sda1
pvcreate /dev/sdb1
2. create volume group
vgcreate VolGroup00 /dev/sda1 /dev/sdb1
3. create logical volume
lvcreate -L 10G /dev/VolGroup00/LogVol01
lvcreate -L 10G /dev/VolGroup00/LogVol02
T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2008 12:31 AM
тАО10-14-2008 12:31 AM
Re: how to expand disk space on linux
1. Backup your data
2. Add a new drive
3. pvcreate /dev/sda1
4. pvcreate /dev/sdb1 (assuming the new drive's been partitioned... etc)
5. Create your volume group using vgcreate
6. Create your logical volume using lvcreate
7. Create a filesystem with mkfs.ext3
8. Edit your /etc/fstab
9. Mount it and restore your backup.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2008 04:45 AM
тАО10-14-2008 04:45 AM
Solutionit hasn't become fully clear to me if you want to change from old partition to LVM layout?
Since you applied the pvdisplay command unsuccessfully on /dev/sda1 this partition obviously isn't an LVM PV and thus can't be used to extend any volumes.
Unless you provide pvcreate with a whole disk but rather a dedicated partition (as we usually do) this partition needs to be marked as being of type 0x8e by some tool like fdisk.
Let me show you on one of my boxes.
Either the pvscan or pvs command will list all valid LVM PVs on the system
(to be more precise, only those which aren't exempt by an "r" filter in lvm.conf which sometimes is necessary if you e.g. use DRBD devices)
[root@nagsaz:~]
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vgrh lvm2 a- 9.62G 560.00M
/dev/sda4 vgdata lvm2 a- 9.62G 7.38G
So for that to work both partitions /dev/sda[24] must have been assigned the 0x8e type flag, and as fdisk proves they have.
[root@nagsaz:~]
# fdisk -l /dev/sda
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 33 265041 83 Linux
/dev/sda2 34 1289 10088820 8e Linux LVM
/dev/sda3 1290 1353 514080 82 Linux swap / Solaris
/dev/sda4 1354 2610 10096852+ 8e Linux LVM
If you run the fdisk -l command on your system you will see if all cylinders are already allocated by some partition or if you have some still left free.
If the latter is the case then you can create a new partition to make up a new volume group.
To do this run fdisk without any options but only the appropriate disk device as argument.
BEWARE, BEFORE YOU CARRY ON BACKUP ALL YOUR DATA!
But the least you should do is backup the MBR of the disk to some safe place.
This can easily done like so
# dd if=/dev/sda bs=512 count=1 | ssh remuser@remhost dd of=/some/backupdir/host-xyz_sda.mbr
And to be on the safe side also capture an sfdisk dump
# sfdisk -d /dev/sda | ssh remuser@remhost 'cat >/some/backupdir/host-xyz_sfdisk_sda.txt'
Now it depends if you previously partitioned just using primary partitions or if your 4th and last viable partition is a so called extended partition (container).
In the latter case you can at heart's content create several partitions within this extended one which you can all give the 8e type flag (well there is an upper boundary of course)
If on the other hand you have all four possible primary partitions used up then you already reached the end.
However, if you have less than four partitions and cylinders still left you may as well create another primary partition and make it 8e.
Do the following (after the backup!)
press those keys while in fdisk:
"n" will create an new partition, and will ask you the offset for the starting cylinder.
If you previously partitioned sensibly without any gaps then you can safely press return and accept the offered default.
Next it will ask you for the last cylinder and default for the very last that is still available.
If that's ok again just press return.
If you however want to specify a size rather than an offset you may do so by typing e.g. "+4g" to make the partition roughly 4 GB big (there's usually some rounding deviation), provided the still free cylinders allow for this size. If not you will get an error and asked to retry anyway.
Next you must select the partition's type by pressing "t" and will be asked to which partition No. this should apply (note, fdisk contrary to usual IT convention starts numbering with 1).
So if you created the fourth partitions press 4.
Next you will be asked for the type code, which I already mentioned several times.
So type "8e" or if you are curiuos "l" to see a long list of partition types fdisk knows of.
Finally press "p" to get a display of your changes.
If all is acceptable press "w" to have the new partition table written and exited from fdisk. It is at this point where a restore from your backup might become a bailout.
Now there is a really annoying glitch with most RH kernels, and fdisk will probably emit such a warning.
The running kernel doesn't yet know of the new partition table and thus to carry on usually a reboot is required.
I once during a Linux Tag here in Berlin was so bold to ask RH kernel legend Alan Cox about this annoying "feature" after a talk of his, and even he couldn't give me a compelling reason for that and passed the blame to the LVM layer developers ;-)
So if you are ready reboot
# init 6
After the system is back you can now create your first PV,
so assuming we chose sda4 you would
# pvcreate /dev/sda4
Ther rest is the usal LVM stuff like
# vgcreate vgdata /dev/sda4
# vgs
# lvcreate -L 1g -n lv_something vgdata
# mke2fs -j /dev/vgdata/lv_something
# mkdir -p /mnt/somewhere
# mount /dev/vgdata/lv_something /mnt/somewhere
And later when you run out of space
# lvextend -L +512m /dev/vgdata/lv_something
# resize2fs /dev/vgdata/lv_something
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2008 08:11 AM
тАО10-14-2008 08:11 AM
Re: how to expand disk space on linux
Ralph:
it hasn't become fully clear to me if you want to change from old partition to LVM layout?
Since you applied the pvdisplay command unsuccessfully on /dev/sda1 this partition obviously isn't an LVM PV and thus can't be used to extend any volumes.
[root@nagsaz:~]
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vgrh lvm2 a- 9.62G 560.00M
/dev/sda4 vgdata lvm2 a- 9.62G 7.38G
So for that to work both partitions /dev/sda[24] must have been assigned the 0x8e type flag, and as fdisk proves they have.
[root@nagsaz:~]
# fdisk -l /dev/sda
thanks again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-14-2008 01:01 PM
тАО10-14-2008 01:01 PM
Re: how to expand disk space on linux
first thing i got to do before adding the drive to a volume group is figure out which controller/bus it's on is there a way to do this without rebooting the system?
kind of like ioscan on hpux?
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2008 03:41 AM
тАО10-15-2008 03:41 AM
Re: how to expand disk space on linux
No, fdisk would only modify the partition table on the disk.
So if you somehow buggered up your partition table, and haven't yet done the following with the new partition(s): created new filesystems, MD Raid or swap devices, or used them as PV for LVM then no data should be touched.
That's why I advised you to run the "sfdisk -d" dump command before issuing the "w" write command in fdisk.
In such a case you could restore your old partition table by simply reading it from stdin.
e.g.
# ssh remuser@remhost cat /some/backupdir/host-xyz_sfdisk_sda.txt | sfdisk /dev/sda
or if you have the dump already on localhost more easily
# sfdisk /dev/sda < /some/localbackupdir/fdisk_sda.txt
This is also very handy where you need exactly identical partition layouts as when you mirror your root disks by SW MD raidtools (as we do on our boxes), or every time you need to replace a failed disk.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2008 03:58 AM
тАО10-15-2008 03:58 AM
Re: how to expand disk space on linux
This very much depends on your hardware.
I already had cases where the vendor claimed that when I replace a failed internal scsi disk by plugging the new disk in the emptied slot the system should autodetect the new disk, and it actually didn't, so that I was forced to reboot for the kernel to become aware of the new disk so that the sfdisk command to write a partition table on it could be applied.
Sometimes one could force a bus rescan by issuing something like this (select the right HBA)
# echo "- - -" > /sys/class/scsi_host/host0/scan
But this isn't guaranteed to work everywhere.
>kind of like ioscan on hpux?
not really, but new devices should appear in the virtual procfs mounted as /proc
Most Linux tools for HW sensing/detection mainly read from /proc it appears to me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2008 04:10 AM
тАО10-15-2008 04:10 AM
Re: how to expand disk space on linux
Although there are hacks out there that show how this can be done, there is one thing you should avoid. Don't put your /boot on an LV because this can cause a lot of headaches when you need to run a bare metal recovery.
It is best to spare a small entirely separate standard linux partition (type 0x83) and mount /boot on that.
But there is no issue putting /, /var, /usr, /home etc. on separate LVM volumes.
In fact LVM gives you greater flexibility when you later need to online extend your /var or /.
Added to this you have free snapshot facility of all your LVs which is really a great thing for fast failback backups or to clone a living / and /var.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2008 08:37 AM
тАО10-15-2008 08:37 AM
Re: how to expand disk space on linux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2008 09:44 AM
тАО10-15-2008 09:44 AM
Re: how to expand disk space on linux
should i copy this line exactley as it is?
not sure about right HBA.
Sometimes one could force a bus rescan by issuing something like this (select the right HBA)
# echo "- - -" > /sys/class/scsi_host/host0/scan
But this isn't guaranteed to work everywhere
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-15-2008 11:51 PM
тАО10-15-2008 11:51 PM
Re: how to expand disk space on linux
>should i copy this line exactley as it is?
>not sure about right HBA.
It depends to which controller your disk(s) is/are attached.
Usually, you have several controllers like in this box
$ ls -ld /sys/class/scsi_host/host?
drwxr-xr-x 2 root root 0 20. Apr 18:38 /sys/class/scsi_host/host0
drwxr-xr-x 2 root root 0 20. Apr 18:38 /sys/class/scsi_host/host1
drwxr-xr-x 2 root root 0 20. Apr 18:38 /sys/class/scsi_host/host2
On the other hand on many virtual hosts of ours they often only see one controller.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-16-2008 07:39 AM
тАО10-16-2008 07:39 AM