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

本文详细介绍如何在Linux环境下进行文件查找与复制、调整逻辑卷大小、创建交换分区等操作。主要内容包括:通过find命令定位属于特定用户的文件并复制到指定文件夹;扩大或缩小逻辑卷(LVM)而不需卸载;创建并激活交换分区,确保系统启动时可用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 make it 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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值