Summary Title linux (II)

1. Describe what GPT is how it should use

Abbreviations GUID partition table, which is a hard disk partition table. Use tools to support GPT partition table of hard disk partition, format the partition and then mount the partition is ready for use.

2. Create a 10G partition, and format for the ext4 file system. Claim:

(1) block size of 2048, 20% reserve space, the volume label MYDATA
(2) to mount / mydata directory, run automatically ban mount, not updated file access time stamp
(3) bootable automatically mount

parted /dev/sda mkpart logical 155GB 165GB
partprobe
mkfs.ext4 /dev/sda7
mke2fs -b 2048 -m 20 -L MYDATA /dev/sda7
mount -o auto,noexec,nodiratime /dev/sda7 /mydata
echo UUID=$(blkid -s UUID /dev/sda7 | cut -d '"' -f2) /MYDATA  ext4  auto,noexec,nodiratime  0 0 >> /etc/fstab

3. Create a swap partition size for the 1G and enable

parted /dev/sda mkpart logical 165GB 166GB
mkswap /dev/sda8
swapon /dev/sda8
swapon -s

4. Calculation scripting / etc / passwd file 10 and the user 20 of the user id and

declare -i uid1=$(sed -n '10p' /etc/passwd | cut -d: -f3)
declare -i uid2=$(sed -n '20p' /etc/passwd | cut -d: -f3)
let sum=$uid1+$uid2
echo "the two user uid's sum is $sum."
unset uid1
unset uid2
unset sum

5.将当前主机名保存至hostName变量中,主机名如果为空,或者为 _localhost.localdomain则将设置为www.magedu.com
hostName=$(hostname)
[ -z $hostName -o "$hostName" = "localhost.localdomain" ] && hostName="www.magedu.com"
echo $hostName
unset hostName

6. scripting, passing a user name from the command-line arguments, judge id number is even or odd


id=$(id -u $1)
echo $id | grep '^[0-9]+$' &>/dev/null && declare -i remainder=$id%2 || { echo "please input valid username.";exit; }
[ "$remainder" = "0" ] && echo "Your uid is even number." || echo "Your uid is odd number."

7.lvm basic applications and extend down to achieve.


PV  物理卷,它是lvm基本的存储逻辑块,包含lvm的管理参数。
VG  卷组,由多个PV组成,还可以在它上创建一个或多个LV。
LV  逻辑卷,和磁盘分区类似,它上就可以建立文件系统了。
PE  物理块,lvm寻址PE的最小单位,PV的大小就是PE的整数倍。PE默认大小是4MB,它是可以配置的。
LE  逻辑块,LV可被寻址的最小单位,在同一个VG中LE和PE的大小是相等的。

Steps to create a LV


创建物理卷
pvcreate /dev/sda7
创建卷组并分配物理卷
vgcreate vgname /dev/sda7
从卷组中创建逻辑卷
lvcreate -L 1G -n test vgname
格式化逻辑卷
mkfs.xfs /dev/vgname/test 
挂载逻辑卷
mount /dev/vgname/test /mnt

Logical extension of reduced

扩展逻辑卷
lvresize -r -L 3G /dev/vg0/test1
缩小逻辑卷(xfs 文件系统不支持缩小,ext文件系统可以)
lvresize -r -L -1G /dev/vg0/test1
如文件系统是xfs会报如下错误
fsadm: Xfs filesystem shrinking is unsupported.

Guess you like

Origin blog.51cto.com/14414023/2422509