in Linux, rhce

RHCE6 Preperation (3) – find & copy, lvm resize, swap partition create

1, find the file belong to lucy and copy to a folder,

create the find folder,

mkdir /tmp/findfiles

find the file the owner is lucy, use the parameter -user and -exec

find / -user lucy -exec cp -a {} /tmp/findfiles \;

2, enlarge the lvm, no need to umount,

lvextend -L 190M /dev/mapper/vgsrv-common

then extend the file system,

resize2fs /dev/mapper/vgsrv-common

you can also use the UI to edit the logic volume size,

yum install system-config-lvm
system-config-lvm

In the logic volume size, click the ‘edit properties’, and drag the size bar to modify the size.

3, shrink another lvm, needs to umount first.

umount /shrink

needs to check the file system,

e2fsck –f /dev/mapper/vgsrv-shrink

shrink the file system first,

resize2fs /dev/mapper/vgsrv-shrink 200M

shrink the lvm

lvreduce -L 200M /dev/mapper/vgsrv-shrink

mount again,

mount -a

4, make swap partition and make it usable after booting,

create the swap partition and make the label as 0x82

fdisk /dev/sda
n to create the partition, size as +512M, t to change the label to 0x82,

Partprobe not working, needs to reboot to make the swap partition be seen by mkswap command, or use the following command to usable,

partx -a /dev/sda

activate swap,

mkswap /dev/sda3

start to use the swap,

swapon /dev/sda3

display the swap partition,

swapon -s

write into the /etc/fstab to make the swap partition bootable.

vim /etc/fstab
/dev/sda3 swap swap defaults 0 0

another way to create swap partition is to create file as following,

dd if=/dev/zero of=file bs=1M count=756  #to generate a file size as 756M
mkswap file
swapon file
vim /etc/fstab  #modify the fstab file to auto mount

/root/file swap swap defaults 0 0

to check the result, using following commands,

cat /proc/swaps
free -l
swapon -s

swap partition create can refer to this link:

http://computernetworkingnotes.com/file-system-administration/how-to-create-swap-partition.html

Write a Comment

Comment

seventeen − five =