Map new LVM
Contents
Presentation
IPBRICK.OS v6.3 installed in LVM. Clients decides to map a new HDD to migrate users data. Here we describe the process to prepare a new LVM volume and move an existing homedirs/workareas to the new LVM filesystem.
NOTE
IMPORTANT : this procedure is to be executed at IPBRICK.OS linux command line as super-user (su - root). This procedure is to be executed by a system administrator with some linux console knowledge. The instructions here presented were collected from a real scenario, meanwhile you are required to check, verifiy and adapt to your own installation.
Contents
In the following sections you'll find:
- Scenarios - list of typical applications
- Technical procedures
Scenarios
The typical scenario is:
- one disk for operating system
- one disk for users data
- one disk for database binaries
These apply to:
- FileServer - users data separated from the operating system (OS) installation
- MailServer - users data separated from the OS
- iPortalDoc - data warehouse separated from the OS, database binaries in an independente volume
Technical Procedures
In this section we will be working with the following setup:
- IPBRICK.OS v6.3
- OS installation using LVM
- HDD setup:
- sda - the first HDD - OS installation
- sdb - the second HDD - for user data
- sdc - the third HDD - for user data
We will be working with LVM. All physical disks are to be grouped in one new volume group.
Identify Blocks/Disks
LSBLK : helps you identify physical disks and their current assignment
ipbrick:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 50G 0 disk ├─sda1 8:1 0 1.9G 0 part └─sda2 8:2 0 48.1G 0 part ├─vgsystem1-lvos (dm-0) 254:0 0 15G 0 lvm / ├─vgsystem1-lvswap (dm-1) 254:1 0 2G 0 lvm [SWAP] ├─vgsystem1-lvvar (dm-2) 254:2 0 20G 0 lvm /var └─vgsystem1-lvdata1 (dm-3) 254:3 0 11.1G 0 lvm /srv/data1 sdb 8:16 0 2T 0 disk sdc 8:32 0 2T 0 disk sr0 11:0 1 1024M 0 rom ipbrick:~#
Partitioning
PARTED : the tool to create partition table and partitions
ipbrick:~# parted /dev/sdb GNU Parted 2.3 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mktable gpt (parted) print Model: Msft Virtual Disk (scsi) Disk /dev/sdb: 2199GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Number Start End Size File system Name Flags (parted) mkpart Partition name? []? File system type? [ext2]? Start? 1 End? 2199GB (parted) print Model: Msft Virtual Disk (scsi) Disk /dev/sdb: 2199GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 2199GB 2199GB (parted) select /dev/sdc Using /dev/sdc (parted) print Error: /dev/sdc: unrecognised disk label (parted) mktable gpt (parted) print Model: Msft Virtual Disk (scsi) Disk /dev/sdc: 2199GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Number Start End Size File system Name Flags (parted) mkpart Partition name? []? File system type? [ext2]? Start? 1 End? 2199GB (parted) print Model: Msft Virtual Disk (scsi) Disk /dev/sdc: 2199GB Sector size (logical/physical): 512B/4096B Partition Table: gpt Number Start End Size File system Name Flags 1 1049kB 2199GB 2199GB (parted) quit Information: You may need to update /etc/fstab. ipbrick:~#
Check the new blocks:
ipbrick:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 50G 0 disk ├─sda1 8:1 0 1.9G 0 part └─sda2 8:2 0 48.1G 0 part ├─vgsystem1-lvos (dm-0) 254:0 0 15G 0 lvm / ├─vgsystem1-lvswap (dm-1) 254:1 0 2G 0 lvm [SWAP] ├─vgsystem1-lvvar (dm-2) 254:2 0 20G 0 lvm /var └─vgsystem1-lvdata1 (dm-3) 254:3 0 11.1G 0 lvm /srv/data1 sdb 8:16 0 2T 0 disk └─sdb1 8:17 0 2T 0 part sdc 8:32 0 2T 0 disk └─sdc1 8:33 0 2T 0 part sr0 11:0 1 1024M 0 rom ipbrick:~#
LVM configuration
PVCREATE : initialize the physical volumes
ipbrick:~# pvcreate /dev/sdb1 /dev/sdc1 Writing physical volume data to disk "/dev/sdb1" Physical volume "/dev/sdb1" successfully created Writing physical volume data to disk "/dev/sdc1" Physical volume "/dev/sdc1" successfully created ipbrick:~#
VGCREATE : initialize the volume group
ipbrick:~# vgcreate vgshares /dev/sdb1 /dev/sdc1 Volume group "vgshares" successfully created ipbrick:~#
VGDISPLAY : displays information on the volume groups
ipbrick:~# vgdisplay vgshares --- Volume group --- VG Name vgshares System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 4.00 TiB PE Size 4.00 MiB Total PE 1048574 Alloc PE / Size 0 / 0 Free PE / Size 1048574 / 4.00 TiB VG UUID 3htRDP-4EEE-xG24-VBrj-cUYP-dkUW-m1h8Ya ipbrick:~#
LVCREATE : creates logical volume
ipbrick:~# lvcreate -l 100%FREE -n lvshares vgshares Logical volume "lvshares" created ipbrick:~#
LVDISPLAY : displays information on the logical volume
ipbrick:~# lvdisplay vgshares --- Logical volume --- LV Path /dev/vgshares/lvshares LV Name lvshares VG Name vgshares LV UUID JrTaAv-WYtf-SDCe-tzHl-6e0Z-VAJF-rjV5dn LV Write Access read/write LV Creation host, time gestdoc, 2018-04-20 18:02:24 +0100 LV Status available # open 0 LV Size 4.00 TiB Current LE 1048574 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 254:4 ipbrick:~#
FileSystem Configuration
MKFS.EXT4 : initialize filesystem with EXT4 format
ipbrick:~# mkfs.ext4 /dev/vgshares/lvshares mke2fs 1.42.5 (29-Jul-2012) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 268435456 inodes, 1073739776 blocks 53686988 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 32768 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 102400000, 214990848, 512000000, 550731776, 644972544 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done ipbrick:~#
Test-drive the new filesystem:
ipbrick:~# mount /dev/vgshares/lvshares /mnt/ ipbrick:~# df -h Filesystem Size Used Avail Use% Mounted on rootfs 15G 4.6G 9.4G 33% / udev 10M 0 10M 0% /dev tmpfs 1.6G 964K 1.6G 1% /run /dev/mapper/vgsystem1-lvos 15G 4.6G 9.4G 33% / tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.2G 0 3.2G 0% /run/shm /dev/mapper/vgsystem1-lvvar 20G 1.5G 18G 8% /var /dev/mapper/vgsystem1-lvdata1 11G 44M 11G 1% /srv/data1 /dev/mapper/vgsystem1-lvdata1 11G 44M 11G 1% /home1 /dev/mapper/vgsystem1-lvdata1 11G 44M 11G 1% /home2 /dev/mapper/vgsystem1-lvdata1 11G 44M 11G 1% /var/spool/hylafax /dev/mapper/vgshares-lvshares 4.0T 67M 3.8T 1% /mnt ipbrick:~# umount /mnt ipbrick:~#
FSTAB - Mount at boot time
BLKID : identify blocks id
ipbrick:~# blkid /dev/sda2: UUID="exMrHD-qgY3-c8cy-Ao0t-Z6TG-JNiG-L2boKk" TYPE="LVM2_member" /dev/mapper/vgsystem1-lvos: LABEL="LVOS" UUID="7f1dd815-0e0e-4148-bf55-e3b443de0afd" TYPE="ext4" /dev/mapper/vgsystem1-lvswap: UUID="b6de4b36-9f16-432b-9475-636008e5efed" TYPE="swap" /dev/mapper/vgsystem1-lvvar: LABEL="LVVAR" UUID="69a75bac-56e9-4ec6-b3a8-3f31b91019a3" TYPE="ext4" /dev/mapper/vgsystem1-lvdata1: LABEL="LVDATA1" UUID="c8c681b9-6cd5-40a1-a075-279b7745ccce" TYPE="ext4" /dev/sdc1: UUID="qXYDO1-oExh-O1Bb-3swI-exLi-o8YC-ReAPQb" TYPE="LVM2_member" /dev/sdb1: UUID="cuECJ4-w5Hl-PzMd-btZ3-8I49-tcye-VBkS4x" TYPE="LVM2_member" /dev/mapper/vgshares-lvshares: UUID="31875c98-c036-4718-ba3e-1d4212fe091b" TYPE="ext4" ipbrick:~#
FSTAB : filesystem fstab file
ipbrick:~# cat /etc/fstab # /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/mapper/vgsystem1-lvos / ext4 errors=remount-ro 0 1 /dev/vgsystem1/lvswap none swap sw 0 0 /dev/fd0 /floppy auto user,noauto 0 0 /dev/cdrom /cdrom iso9660 ro,user,noauto 0 0 /dev/mapper/vgsystem1-lvvar /var ext4 defaults 0 2 /dev/mapper/vgsystem1-lvdata1 /srv/data1 ext4 defaults,usrquota,grpquota,user_xattr,acl 0 2 /srv/data1/home1 /home1 none bind 0 0 /srv/data1/home2 /home2 none bind 0 0 LABEL=ipbrick-D /opt/system/backupDB auto user,noauto 0 0 /home1/_fax /var/spool/hylafax none bind 0 0 ipbrick:~#
Create mount point, update fstab and do the mount.
ipbrick:~# mkdir /home3 ipbrick:~# echo "/dev/mapper/vgshares-lvshares /home3 ext4 defaults,usrquota,grpquota,user_xattr,acl 0 2" >> /etc/fstab ipbrick:~# cat /etc/fstab # /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/mapper/vgsystem1-lvos / ext4 errors=remount-ro 0 1 /dev/vgsystem1/lvswap none swap sw 0 0 /dev/fd0 /floppy auto user,noauto 0 0 /dev/cdrom /cdrom iso9660 ro,user,noauto 0 0 /dev/mapper/vgsystem1-lvvar /var ext4 defaults 0 2 /dev/mapper/vgsystem1-lvdata1 /srv/data1 ext4 defaults,usrquota,grpquota,user_xattr,acl 0 2 /srv/data1/home1 /home1 none bind 0 0 /srv/data1/home2 /home2 none bind 0 0 LABEL=ipbrick-D /opt/system/backupDB auto user,noauto 0 0 /home1/_fax /var/spool/hylafax none bind 0 0 /dev/mapper/vgshares-lvshares /home3 ext4 defaults,usrquota,grpquota,user_xattr,acl 0 2 ipbrick:~# mount /home3 ipbrick:~# df -h Filesystem Size Used Avail Use% Mounted on rootfs 15G 4.6G 9.4G 33% / udev 10M 0 10M 0% /dev tmpfs 1.6G 964K 1.6G 1% /run /dev/mapper/vgsystem1-lvos 15G 4.6G 9.4G 33% / tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.2G 0 3.2G 0% /run/shm /dev/mapper/vgsystem1-lvvar 20G 1.5G 18G 8% /var /dev/mapper/vgsystem1-lvdata1 11G 44M 11G 1% /srv/data1 /dev/mapper/vgsystem1-lvdata1 11G 44M 11G 1% /home1 /dev/mapper/vgsystem1-lvdata1 11G 44M 11G 1% /home2 /dev/mapper/vgsystem1-lvdata1 11G 44M 11G 1% /var/spool/hylafax /dev/mapper/vgshares-lvshares 4.0T 67M 3.8T 1% /home3 ipbrick:~#
Initialize basic structure:
ipbrick:~# cd /home3/ ipbrick:/home3# mkdir _accounts _shares ipbrick:/home3# ls -al total 32 drwxr-xr-x 5 root root 4096 Apr 20 18:15 . drwxr-xr-x 29 root root 4096 Apr 20 18:12 .. drwxr-xr-x 2 root root 4096 Apr 20 18:15 _accounts drwx------ 2 root root 16384 Apr 20 18:05 lost+found drwxr-xr-x 2 root root 4096 Apr 20 18:15 _shares ipbrick:/home3#