You are not logged in.

#1 2013-05-25 04:26:59

morfik
Member
From: Europe/Poland
Registered: 2013-03-14
Posts: 24
Website

[SOLVED] Setting up LVM on top of the encrypted partition

This is my disk setup:

[morfik@morfina][~]% lsblk
NAME                    MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
sda                       8:0    0 74.5G  0 disk  
├─sda1                    8:1    0   28G  0 part  
├─sda2                    8:2    0  957M  0 part  /boot
├─sda3                    8:3    0    1K  0 part  
├─sda5                    8:5    0 33.1G  0 part  
│ └─sda5_crypt          254:0    0 33.1G  0 crypt 
│   ├─lorfik_crypt-root 254:1    0    5G  0 lvm   /
│   ├─lorfik_crypt-usr  254:2    0   12G  0 lvm   /usr
│   ├─lorfik_crypt-home 254:3    0    5G  0 lvm   /home
│   ├─lorfik_crypt-tmp  254:4    0    3G  0 lvm   /tmp
│   ├─lorfik_crypt-var  254:5    0    6G  0 lvm   /var
│   ├─lorfik_crypt-log  254:6    0    1G  0 lvm   /var/log
│   └─lorfik_crypt-swap 254:7    0  1.1G  0 lvm   [SWAP]
└─sda6                    8:6    0 12.6G  0 part  /media/backup
sdb                       8:16   1 14.5G  0 disk  
├─sdb1                    8:17   1  6.6G  0 part  /media/morfik/arch
├─sdb2                    8:18   1  4.9G  0 part  
└─sdb3                    8:19   1  3.1G  0 part  /media/morfik/fat
[morfik@morfina][~]% ls -al /dev/mapper 
total 0
drwxr-xr-x  2 root root     220 May 24 08:23 ./
drwxr-xr-x 18 root root    3.3K May 24 08:24 ../
crw-------  1 root root 10, 236 May 24 08:24 control
lrwxrwxrwx  1 root root       7 May 24 08:24 sda5_crypt -> ../dm-0
lrwxrwxrwx  1 root root       7 May 24 08:24 lorfik_crypt-home -> ../dm-3
lrwxrwxrwx  1 root root       7 May 24 08:24 lorfik_crypt-log -> ../dm-6
lrwxrwxrwx  1 root root       7 May 24 08:24 lorfik_crypt-root -> ../dm-1
lrwxrwxrwx  1 root root       7 May 24 08:24 lorfik_crypt-swap -> ../dm-7
lrwxrwxrwx  1 root root       7 May 24 08:24 lorfik_crypt-tmp -> ../dm-4
lrwxrwxrwx  1 root root       7 May 24 08:24 lorfik_crypt-usr -> ../dm-2
lrwxrwxrwx  1 root root       7 May 24 08:24 lorfik_crypt-var -> ../dm-5
[morfik@morfina][~]% cat /etc/fstab 
# 
# /etc/fstab: static file system information
#
# <file system>	<dir>	<type>	<options>	<dump>	<pass>
# /dev/mapper/lorfik_crypt-root LABEL=root
UUID=1423029a-96da-44fa-bba8-620528e5eb69	/         	ext4      	rw,relatime,data=ordered	0 1

# /dev/mapper/lorfik_crypt-usr LABEL=usr
UUID=727179d2-ef54-46cb-8f1c-905e15635297	/usr      	ext4      	rw,relatime,data=ordered	0 2

# /dev/mapper/lorfik_crypt-home LABEL=home
UUID=5cdc5422-a831-450d-a3bc-a1814c083a97	/home     	ext4      	rw,relatime,data=ordered	0 2

# /dev/mapper/lorfik_crypt-tmp LABEL=tmp
UUID=a59e91b5-1c7f-42c7-9fac-e99b2bbcc52c	/tmp      	ext4      	rw,relatime,data=ordered	0 2

# /dev/mapper/lorfik_crypt-var LABEL=var
UUID=7593eea9-40ed-48a8-956b-65accea73c48	/var      	ext4      	rw,relatime,data=ordered	0 2

# /dev/mapper/lorfik_crypt-log LABEL=log
UUID=393d0a9d-eb85-438c-b230-f888fdd6fb94	/var/log  	ext4      	rw,relatime,data=ordered	0 2

# /dev/sda6 LABEL=backup
UUID=70c13ef3-bf99-436b-b444-bac4d7c0d2d8	/media/backup	ext4      	rw,relatime,data=ordered	0 2

# /dev/sda2 LABEL=boot
UUID=76b262f9-2303-4898-b649-c6acd8e38518	/boot     	ext4      	rw,relatime,data=ordered	0 2

# /dev/mapper/lorfik_crypt-swap
UUID=ee15f7c0-e90c-434a-aa20-e953a275568d	none      	swap      	defaults  	0 0
[root@morfina][/home/morfik]# pvscan 
  PV /dev/mapper/sda5_crypt   VG lorfik_crypt   lvm2 [33.05 GiB / 0    free]
  Total: 1 [33.05 GiB] / in use: 1 [33.05 GiB] / in no VG: 0 [0   ]
[root@morfina][/home/morfik]# pvdisplay 
  --- Physical volume ---
  PV Name               /dev/mapper/sda5_crypt
  VG Name               lorfik_crypt
  PV Size               33.05 GiB / not usable 1.86 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              8461
  Free PE               0
  Allocated PE          8461
  PV UUID               ejvrJD-lkro-N90a-SwvQ-cx9s-On5i-G7fzBY

[root@morfina][/home/morfik]# lvscan 
  ACTIVE            '/dev/lorfik_crypt/root' [5.00 GiB] contiguous
  ACTIVE            '/dev/lorfik_crypt/usr' [12.00 GiB] contiguous
  ACTIVE            '/dev/lorfik_crypt/home' [5.00 GiB] contiguous
  ACTIVE            '/dev/lorfik_crypt/tmp' [3.00 GiB] contiguous
  ACTIVE            '/dev/lorfik_crypt/var' [6.00 GiB] contiguous
  ACTIVE            '/dev/lorfik_crypt/log' [1.00 GiB] contiguous
  ACTIVE            '/dev/lorfik_crypt/swap' [1.05 GiB] contiguous

[root@morfina][/home/morfik]# lvdisplay 
  --- Logical volume ---
  LV Path                /dev/lorfik_crypt/root
  LV Name                root
  VG Name                lorfik_crypt
  LV UUID                4SmVM3-fszz-cnnb-10r3-oFZ1-GTSF-Y3Efqt
  LV Write Access        read/write
  LV Creation host, time archiso, 2013-05-19 03:12:56 +0200
  LV Status              available
  # open                 1
  LV Size                5.00 GiB
  Current LE             1280
  Segments               1
  Allocation             contiguous
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:1
   
  --- Logical volume ---
  LV Path                /dev/lorfik_crypt/usr
  LV Name                usr
  VG Name                lorfik_crypt
  LV UUID                TyX9SI-ktm2-Xdrg-TTNv-66hJ-0kEd-2UTJ8y
  LV Write Access        read/write
  LV Creation host, time archiso, 2013-05-19 03:13:03 +0200
  LV Status              available
  # open                 1
  LV Size                12.00 GiB
  Current LE             3072
  Segments               1
  Allocation             contiguous
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:2
   
  --- Logical volume ---
  LV Path                /dev/lorfik_crypt/home
  LV Name                home
  VG Name                lorfik_crypt
  LV UUID                4yZxJW-weku-a02U-Tti1-vjan-jRB7-R5VzFp
  LV Write Access        read/write
  LV Creation host, time archiso, 2013-05-19 03:13:08 +0200
  LV Status              available
  # open                 1
  LV Size                5.00 GiB
  Current LE             1280
  Segments               1
  Allocation             contiguous
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:3
   
  --- Logical volume ---
  LV Path                /dev/lorfik_crypt/tmp
  LV Name                tmp
  VG Name                lorfik_crypt
  LV UUID                zX7PfX-mT1z-mosb-0Atq-oam0-SA2L-vObbT9
  LV Write Access        read/write
  LV Creation host, time archiso, 2013-05-19 03:13:14 +0200
  LV Status              available
  # open                 1
  LV Size                3.00 GiB
  Current LE             768
  Segments               1
  Allocation             contiguous
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:4
   
  --- Logical volume ---
  LV Path                /dev/lorfik_crypt/var
  LV Name                var
  VG Name                lorfik_crypt
  LV UUID                tnYxOR-Fmlg-m4WU-6Hso-0lHo-OQu9-5b4z7D
  LV Write Access        read/write
  LV Creation host, time archiso, 2013-05-19 03:13:21 +0200
  LV Status              available
  # open                 1
  LV Size                6.00 GiB
  Current LE             1536
  Segments               1
  Allocation             contiguous
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:5
   
  --- Logical volume ---
  LV Path                /dev/lorfik_crypt/log
  LV Name                log
  VG Name                lorfik_crypt
  LV UUID                4UQanU-QpFc-3S4b-vdMx-vJma-L6yi-bi04AP
  LV Write Access        read/write
  LV Creation host, time archiso, 2013-05-19 03:13:25 +0200
  LV Status              available
  # open                 1
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             contiguous
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:6
   
  --- Logical volume ---
  LV Path                /dev/lorfik_crypt/swap
  LV Name                swap
  VG Name                lorfik_crypt
  LV UUID                pFaj67-jADP-zXhO-m2iV-HxS0-zzUI-OSSKa8
  LV Write Access        read/write
  LV Creation host, time archiso, 2013-05-19 03:14:07 +0200
  LV Status              available
  # open                 2
  LV Size                1.05 GiB
  Current LE             269
  Segments               1
  Allocation             contiguous
  Read ahead sectors     auto
  - currently set to     256
  Block device           254:7

[root@morfina][/home/morfik]# vgscan  
  Reading all physical volumes.  This may take a while...
  Found volume group "lorfik_crypt" using metadata type lvm2

[root@morfina][/home/morfik]# vgdisplay 
  --- Volume group ---
  VG Name               lorfik_crypt
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  12
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                7
  Open LV               7
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               33.05 GiB
  PE Size               4.00 MiB
  Total PE              8461
  Alloc PE / Size       8461 / 33.05 GiB
  Free  PE / Size       0 / 0   
  VG UUID               Yo9deC-JD7h-gnEl-fL80-KBzv-Oaeu-JhGW1r
[root@morfina][/home/morfik]# cryptsetup luksDump /dev/sda5       
LUKS header information for /dev/sda5

Version:       	1
Cipher name:   	aes
Cipher mode:   	xts-plain64
Hash spec:     	sha512
Payload offset:	4096
MK bits:       	512
MK digest:     	14 53 36 61 bf fc 60 7b 09 54 24 5f 3c 92 65 d6 ca d8 3d 20 
MK salt:       	cc d0 9c 11 b2 f0 75 5b 59 aa 9c 53 83 95 51 a5 
               	a1 17 3d 32 18 28 67 73 26 36 5a c1 6a aa b5 b8 
MK iterations: 	18750
UUID:          	69c485c2-03b9-48df-8284-e3f48e2c6a7a

Key Slot 0: ENABLED
	Iterations:         	78427
	Salt:               	80 1f f0 95 9e d4 5e 36 32 23 8f e1 6a 5c 9b 8a 
	                      	4e 2d a4 6d e4 50 4b a1 ed ff 93 6c 82 9e 7e a3 
	Key material offset:	8
	AF stripes:            	4000
Key Slot 1: DISABLED
Key Slot 2: DISABLED
Key Slot 3: DISABLED
Key Slot 4: DISABLED
Key Slot 5: DISABLED
Key Slot 6: DISABLED
Key Slot 7: DISABLED

I followed these steps:

# modprobe dm_mod
# cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/sda5
# cryptsetup luksOpen /dev/sda5 sda5_crypt
# pvcreate /dev/mapper/sda5_crypt
# vgcreate lorfik_crypt /dev/mapper/sda5_crypt
# lvcreate -L 5G -C y -n root lorfik_crypt
# lvcreate -L 12G -C y -n usr lorfik_crypt
# lvcreate -L 5G -C y -n home lorfik_crypt
# lvcreate -L 3G -C y -n tmp lorfik_crypt
# lvcreate -L 6G -C y -n var lorfik_crypt
# lvcreate -L 1G -C y -n log lorfik_crypt
# lvcreate -l 100%FREE -C y -n swap lorfik_crypt

# mkfs.ext4 -m 0 -L root /dev/mapper/lorfik_crypt-root
# mkfs.ext4 -m 0 -L usr /dev/mapper/lorfik_crypt-usr
# mkfs.ext4 -m 0 -L home /dev/mapper/lorfik_crypt-home
# mkfs.ext4 -m 0 -L tmp /dev/mapper/lorfik_crypt-tmp
# mkfs.ext4 -m 0 -L var /dev/mapper/lorfik_crypt-var
# mkfs.ext4 -m 0 -L log /dev/mapper/lorfik_crypt-log
# mkswap /dev/mapper/lorfik_crypt-swap
# mkfs.ext4 -m 0 -L boot /dev/sda2

# mount /dev/mapper/lorfik_crypt-root /mnt
# mkdir /mnt/{usr,home,tmp,var,boot}
# mount /dev/mapper/lorfik_crypt-usr /mnt/usr
# mount /dev/mapper/lorfik_crypt-var /mnt/var
# mount /dev/mapper/lorfik_crypt-home /mnt/home
# mount /dev/mapper/lorfik_crypt-tmp /mnt/tmp
# mkdir /mnt/var/log
# mount /dev/mapper/lorfik_crypt-log /mnt/var/log
# mount /dev/sda2 /mnt/boot
# swapon /dev/mapper/lorfik_crypt-swap

# genfstab -U -p /mnt >> /mnt/etc/fstab
# arch-chroot /mnt
# cat /etc/mkinitcpio.conf
	MODULES="nvidia dm_mod ext4 dm_snapshot"
	...
	HOOKS="base udev autodetect modconf block keyboard keymap consolefont encrypt lvm2 resume filesystems fsck usr shutdown timestamp"
# cat /etc/default/grub 
	GRUB_CMDLINE_LINUX_DEFAULT=""
	GRUB_CMDLINE_LINUX="resume=/dev/mapper/lorfik_crypt-swap cryptdevice=/dev/sda5:sda5_crypt"
[root@morfina][/home/morfik]# systemctl list-unit-files | grep lvm
lvm-monitoring.service                  enabled 
lvmetad.service                         static  
lvmetad.socket                          static 

This works as expected -- booting works and hibernation works as well. But there is a problem while pc turns off.

This is the log from tty:

Detaching DM 254:2
Could not detach DM /dev/dm-2 device or resource busy
Detaching DM 254:0
Could not detach DM /dev/dm-0 device or resource busy
Not all DM devices detached, 3 left
Cannot finalize remaining file systems and devices, giving up
Storage is finalized
Successfully changed into root pivot
Returning to initrd
Umounting all devices
Detaching look devices
Disassembling stacked devices
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
device-mapper: remove ioctl on sda5_crypt failed:Device or resource busy
Device sda5_crypt is still in use

And this is the log from journalctl:

May 25 03:26:46 morfina systemd[1]: Deactivating swap /dev/dm-7...
May 25 03:26:46 morfina systemd[1]: Deactivating swap /dev/dm-7...
May 25 03:26:46 morfina systemd[1]: Deactivating swap /dev/dm-7...
May 25 03:26:46 morfina systemd[1]: Deactivating swap /dev/dm-7...
May 25 03:26:46 morfina systemd[1]: Deactivating swap /dev/dm-7...
May 25 03:26:46 morfina systemd[1]: Stopping Graphical Interface.
May 25 03:26:46 morfina systemd[1]: Stopped target Graphical Interface.
May 25 03:26:46 morfina systemd[1]: Stopping Multi-User System.
May 25 03:26:46 morfina systemd[1]: Stopped target Multi-User System.
May 25 03:26:46 morfina systemd[1]: Stopping Login Prompts.
May 25 03:26:46 morfina systemd[1]: Stopped target Login Prompts.
May 25 03:26:46 morfina systemd[1]: Stopping Getty on tty1...
May 25 03:26:46 morfina systemd[1]: Stopped Getty on tty1.
May 25 03:26:46 morfina systemd[1]: Deactivated swap /dev/dm-7.
May 25 03:26:46 morfina systemd[1]: Stopping Permit User Sessions...
May 25 03:26:46 morfina systemd[1]: Stopped Permit User Sessions.
May 25 03:26:46 morfina systemd[1]: Stopping Remote File Systems.
May 25 03:26:46 morfina systemd[1]: Stopped target Remote File Systems.
May 25 03:26:46 morfina login[314]: pam_unix(login:session): session closed for user root
May 25 03:26:46 morfina systemd[1]: systemd-logind.service: main process exited, code=exited, status=1/FAILURE
May 25 03:26:46 morfina systemd[1]: Stopped Login Service.
May 25 03:26:46 morfina systemd[1]: Unit systemd-logind.service entered failed state.
May 25 03:26:46 morfina systemd[1]: Stopping Basic System.
May 25 03:26:46 morfina systemd[1]: Stopped target Basic System.
May 25 03:26:46 morfina systemd[1]: Stopping Paths.
May 25 03:26:46 morfina systemd[1]: Stopped target Paths.
May 25 03:26:46 morfina systemd[1]: Stopping Dispatch Password Requests to Console Directory Watch.
May 25 03:26:46 morfina systemd[1]: Stopped Dispatch Password Requests to Console Directory Watch.
May 25 03:26:46 morfina systemd[1]: Stopping Forward Password Requests to Wall Directory Watch.
May 25 03:26:46 morfina systemd[1]: Stopped Forward Password Requests to Wall Directory Watch.
May 25 03:26:46 morfina systemd[1]: Stopping Setup Virtual Console...
May 25 03:26:46 morfina systemd[1]: Stopped Setup Virtual Console.
May 25 03:26:46 morfina systemd[1]: Stopping Swap.
May 25 03:26:46 morfina systemd[1]: Stopped target Swap.
May 25 03:26:46 morfina systemd[1]: Stopping Local File Systems.
May 25 03:26:46 morfina systemd[1]: Stopped target Local File Systems.
May 25 03:26:46 morfina systemd[1]: Unmounting /mnt...
May 25 03:26:46 morfina systemd[1]: Unmounting /usr...
May 25 03:26:46 morfina systemd[1]: Unmounting /media/backup...
May 25 03:26:46 morfina systemd[1]: Unmounting /boot...
May 25 03:26:46 morfina systemd[1]: Unmounting /tmp...
May 25 03:26:46 morfina systemd[1]: Unmounting /home...
May 25 03:26:46 morfina systemd[1]: Stopped Update UTMP about System Reboot/Shutdown.
May 25 03:26:46 morfina systemd[1]: Unmounting /var/log...
May 25 03:26:46 morfina umount[477]: umount: /usr: target is busy.
May 25 03:26:46 morfina umount[477]: (In some cases useful info about processes that use
May 25 03:26:46 morfina umount[477]: the device is found by lsof(8) or fuser(1))
May 25 03:26:46 morfina systemd[1]: usr.mount mount process exited, code=exited status=32
May 25 03:26:46 morfina systemd[1]: Failed unmounting /usr.
May 25 03:26:46 morfina systemd[1]: var-log.mount mount process exited, code=exited status=32
May 25 03:26:46 morfina systemd[1]: Failed unmounting /var/log.
May 25 03:26:46 morfina systemd[1]: Unmounting /var...
May 25 03:26:46 morfina umount[484]: umount: /var/log: target is busy.
May 25 03:26:46 morfina umount[484]: (In some cases useful info about processes that use
May 25 03:26:46 morfina umount[484]: the device is found by lsof(8) or fuser(1))
May 25 03:26:46 morfina systemd[1]: Unmounted /media/backup.
May 25 03:26:46 morfina systemd[1]: Unmounted /boot.
May 25 03:26:46 morfina systemd[1]: var.mount mount process exited, code=exited status=32
May 25 03:26:46 morfina systemd[1]: Failed unmounting /var.
May 25 03:26:46 morfina systemd[1]: Unmounted /home.
May 25 03:26:46 morfina umount[486]: umount: /var: target is busy.
May 25 03:26:46 morfina umount[486]: (In some cases useful info about processes that use
May 25 03:26:46 morfina umount[486]: the device is found by lsof(8) or fuser(1))
May 25 03:26:46 morfina systemd[1]: Unmounted /tmp.
May 25 03:26:48 morfina systemd[1]: Unmounted /mnt.
May 25 03:26:48 morfina systemd[1]: Starting Unmount All Filesystems.
May 25 03:26:48 morfina systemd[1]: Reached target Unmount All Filesystems.
May 25 03:26:48 morfina systemd[1]: Stopping Local File Systems (Pre).
May 25 03:26:48 morfina systemd[1]: Stopped target Local File Systems (Pre).
May 25 03:26:48 morfina systemd[1]: Stopping Remount Root and Kernel File Systems...
May 25 03:26:48 morfina systemd[1]: Stopped Remount Root and Kernel File Systems.
May 25 03:26:48 morfina systemd[1]: Starting Shutdown.
May 25 03:26:48 morfina systemd[1]: Reached target Shutdown.
May 25 03:26:48 morfina systemd[1]: Starting Final Step.
May 25 03:26:48 morfina systemd[1]: Reached target Final Step.
May 25 03:26:48 morfina systemd[1]: Starting Power-Off...
May 25 03:26:48 morfina systemd[1]: Stopping Monitoring of LVM2 mirrors, snapshots etc. using dmeventd or progress polling...
May 25 03:26:48 morfina systemd[1]: Shutting down.
May 25 03:26:48 morfina lvm[493]: 7 logical volume(s) in volume group "lorfik_crypt" unmonitored
May 25 03:26:48 morfina systemd-journal[195]: Journal stopped

It can't unmount /var , /var/log and /usr . Should this happen? If not, how to remove this issue?

Last edited by morfik (2013-05-26 02:09:52)

Offline

#2 2013-05-25 05:11:55

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Setting up LVM on top of the encrypted partition

Well, /var cannot be unmounted because /var/log cannot be unmounted.  /var/log cannot be unmounted because you are sitll seeing log input.  I would imagine that /usr cannot be unmounted because /var is still being written to, so in essence it is still using programs that are found within /usr.  This is actually one of the causes for why having a separate /usr is broken.  I have to say that I really think your problems are due to your desire to have your filesystem broken down in this way.

The failed to unmount /var is normal.  Of course it will fail to unmount /var as it is in use until the very end.  It can recover from this just fine.  While there is (as you have noticed and implemented correctly) the usr hook, this was really only created to support users who were still using this partitioning once things started to get pretty hairy with having it separate. 

Is there a reason why you need to have a separate /usr?  It would make your life far simpler if you just integrated it into your rootfs.

Offline

#3 2013-05-25 05:56:15

morfik
Member
From: Europe/Poland
Registered: 2013-03-14
Posts: 24
Website

Re: [SOLVED] Setting up LVM on top of the encrypted partition

I'm trying to keep fragmentation of files at bay. For instance, this is from my debian:
/     -   25451 regular files ||  33 non-contiguous files (0.1%)
/usr -  287163 regular files || 138 non-contiguous files (0.0%)
/var -   13995 regular files ||  58 non-contiguous files (0.4%)
/var/log - 320 regular files ||  79 non-contiguous files (22.5%)

I don't know any defrag progs, and when I ask someone about this, people always say that you don't need this on linux. I once had over 50% of fragmented files, so I really try to avoid this issue. I could have all those logical volumes on one encrypted partition (even without lvm), but I don't know how to determine which files are fragmented. Even if I knew, recopying each of the files manually wouldn't be wise. smile

Besides, if I had /var , /var/log and /usr on  / , wouldn't be the same, now with / ?

Offline

#4 2013-05-25 06:05:01

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Setting up LVM on top of the encrypted partition

Okay, so I don't understand though how containing fragmentation to a certain partition will lead to a benefit.  What you are really trying to avoid are seek times, right? So if /var/log is on the same disk as everything else, you are still going to have those seeks occuring and therefore slowing everything else on that disk down, no? I think that this technique is beneficial if you actually have the fragmented filesystem on a separate disk.  But the same disk will have the same problems.

I don't understand the question at the end... "wouldn't be the same, now with /"?  What does that mean?

Also, if you want to defragment something, you can simply "cp -a" it from one place to another, or yu can use something like rsync.  Linux is really neat in that it has everything as a file.  So you can literally just copy all the relevant files from one place to another and have a working bootable system.  No magic boot code or anything like that that is hidden from the user.

In reality though, it is not the /var/log that i think is acusing the problems.  I was simply explaining to you why your logs show those errors.  I think the real problem is having /usr on a separate partition.  Though this is somewhat "supported" in Arch Linux, and I have used this in the past, it is not something I feel as though I could count on.  So...

Me wrote:

Is there a reason why you need to have a separate /usr?  It would make your life far simpler if you just integrated it into your rootfs.

Offline

#5 2013-05-25 10:20:36

morfik
Member
From: Europe/Poland
Registered: 2013-03-14
Posts: 24
Website

Re: [SOLVED] Setting up LVM on top of the encrypted partition

Yeah, but how do I know which files are fragmented? Fsck shows only number of fragmented files, and there is no information as to what file and how many parts the file has. So, it's hard to copy the unknown file. smile But leave this alone for know.

WonderWoofy wrote:

I don't understand the question at the end... "wouldn't be the same, now with /"?  What does that mean?

Correct me if I'm wrong -- root file system won't be unmounted at the shout down, right?  It is mounted at boot, and I thought it will be unmounted, but in the log there is no information about unmounting root file system. So I think I really should try to remove those 3 partition. I'll try it tomorrow and see if the errors will disappear.

Offline

#6 2013-05-25 22:47:22

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,132

Re: [SOLVED] Setting up LVM on top of the encrypted partition

/ is unmounted at shutdown but it will not show in the log since /var (and /var/log) must be unmounted first. Not everything which happens at shutdown can be written to a log on the system shutting down. Closing the logs on disk is part of what is required to unmount everything and shut down.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#7 2013-05-26 02:09:31

morfik
Member
From: Europe/Poland
Registered: 2013-03-14
Posts: 24
Website

Re: [SOLVED] Setting up LVM on top of the encrypted partition

Ok, now it works without a problem, thx. smile

Offline

#8 2013-05-26 02:16:02

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Setting up LVM on top of the encrypted partition

So what is it you ended up actually changing?  It would probably be good to give some close to this thread.

Also, if you have come to what you consider a satisfactory result, please mark the thread as [Solved].

Offline

#9 2013-05-26 02:29:27

morfik
Member
From: Europe/Poland
Registered: 2013-03-14
Posts: 24
Website

Re: [SOLVED] Setting up LVM on top of the encrypted partition

I removed those 3 logical volumes (/usr, /var and /var/log). I also removed "usr" hook from /etc/mkinitcpio.conf. Now system closes without any error on tty and does it very fast as it should.

Offline

#10 2013-05-26 05:12:19

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [SOLVED] Setting up LVM on top of the encrypted partition

That is excellent.  I'm glad you got this working well.  If you feel as though you absolutely need to degragment a given filesystem, just create a new logical volume, then copy all the contents from the original to the new one.  Then use the new one as the new filesystem and delete the old.  By copying over all the contents it will copy each file one at a time, so it will write then sequentially to the disk.  The beauty of LVM is that you can create and destroy partitions very easily, so you can quickly adjust the sizes of the volumes so that you can facilitate this from a running system.  Just be sure to test the new partition (LV) before deleting the original by simply adjusting the fstab and bootloader.

Offline

Board footer

Powered by FluxBB