linux- file system -5

cat / proc / boundaries

cat /proc/mounts

mount [options] -o [option] -t directory file type device mounted
apparatus:
(1) the device file: e.g. / dev / SR0, / dev / sdb1
(2) label: -L 'label name'
(3 ) the UUID: -U 'the UUID'
(. 4) pseudo file system name: proc, sysfs
mount directories:
(1) must already exist, to make use of an empty directory

-t: Specifies the file system type to mount the device
-r: readonly, read-only mount
-w: read-write mount
-n: Do not update / etc / mtab, mount invisible
-a: automatically mount all support automatic mounted device (device defined in the / etc / fstab file)
-L: to label name to specify the device to be mounted
-U: UUID to specify the device to be mounted
-B, - bind: bind given directory to another directory (equivalent to a soft link)
-o [options] :( mount a file system option), multiple options separated by commas
async: asynchronous mode, memory changes, save to buffers, a little after written to disk
sync: sync mode, memory changes, and written to disk
atime / noatime: whether to update atime, contains the directories and files (page file commonly used in web services)
diratime / nodiratime: whether to update the directory atime
Exec / noexec : whether to prohibit an executable file on the device execute permissions
auto / noauto: whether to support the auto-mount, whether to support the -a option
dev / nodev: whether to support the use of device files on the file system
suid / nosuid: whether to support the suid and sgid permissions
remount: heavy Mount
ro: read-only
rw: read-write
user / nouser: whether to allow ordinary users to mount the device, / etc / fstab use
acl: acl enable features on this file system
loop: using the loop device (loop: Popular terms is to file when the device is used, for example: windows paging file)
default: the equivalent rw, suid, dev, exec, auto, nouser, async

        卸载:
        • 查看挂载情况:
        findmnt mount_dir | 设备
        例:findmnt /mnt | /etc/sda1

        • 查看正在访问指定文件系统的进程:
        lsof mount_dir
        fuser -v mount_dir

        • 终止所有在正访问指定的文件系统的进程:
        fuser -km mount_dir

        • 卸载/取消挂载:
        umount DEVICE
        umount mount_dir

  dd命令
  
  dd if=file  of=file  bs=n  count=n
if=file :从某个文件读取数据
of=file :输出到某个文件
bs=size : block size,指定块大小(ibs=obs)
ibs=size :一次读取size个byte
obs=size :一次写size个byte
cbs=size :一次转化size个byte
skip=blocks :从开头忽略blocks个ibs大小的块
seek=blocks :从开头忽略blocks个obs大小的块
count : 复制多少个bs
conv=onversion... :用指定参数转换文件
转换参数:
        ascii :转换ebcdic码为ascii
        ebcdic :转换ascii为ebcdic
        lcase :把大写字符转换为小写
        ucase :把小写转换为大写
        nocreat :不创建输出文件
        noerror :出错时不停止
        notrunc :不截短输出文件
        sync :把输入块填充到ibs个字节,不足的部分用空(NUL)字符补



        示例:
        • 备份MBR:
        dd if=/dev/sda of=/root/mbr.bak bs=512 count=1
        • 破坏MBR中的bootloader:
        dd if=/dev/zero of=/dev/sda bs=64 count=1 seek=446
        • 备份磁盘:• 将sda整盘备份到sdc:
        dd if=/dev/sda of=/dev/sdc
        • 将sda的数据备份到文件中:
        dd if=/dev/sda of=file
        • 备份sda全盘数据并压缩:
        dd if=/dev/sda | gzip >file.gz
        • 将压缩的备份文件恢复到sdc:
        gzip -dc file.gz |dd of=/dev/sdc
        • 销毁磁盘数据:
        dd if=/dev/urandom of=/dev/sda

Save partition table
dd if = / dev / hard disk device file of = / root / save file name bs = 1 count = 512

inode resource depletion process

Delete temporary files
zero-byte files

Custom-created file system block size is specified, the reserved space, file system, volume label

mkfs.ext4 -L TEST -m 1 -b 2048 / dev / sdb2
reduced Logical Volume

Logical Volume Management

dm  :  device  mapper   

设备名 ;/dev/dm-#
软连接 :  
        /dev/mapper/VG_NAME-LV_NAME
        /dev/mapper/vol0-root
        
         /dev/VG_nNAME/LV_NAME
        /dev/vol0/root
        
  pvdisplay  
            pvcreate     /dev/DEVICE
            pvremove   /dev/DEVICE
   
VG
        vgs  
        vgdisplay    
        vgcreate   [-s     #[kmgtpe]]     VOlumegroupname    physicaldevicepath
                        PE大小
        vgextend    volumegroupname      physicaldevice
        
        vgreduce    volumegroupname    physicaldevice   
        
        删除卷组,
        pvmove     vgremove
        
        
LV
       lvs
       lvdisplay
       
       lvvreate   -L  #[mgt]   -n   NAME  Volumgtoup
       lvcreate   -l  60%VG   -n  mylv   testvg  
       lvcreate    -l  100%FREE  -n    yourlv   testvg 
      
      
      删除
     lvremove  /dev/VG_name/LV_name
     
     重设大小
        resize2fs    [-f]   [-F]   [-M]   [-p]   [-P]   device   [new_size ]
        xfs_grows    /mountpoint 
        
扩展与缩减
lvextend       -L  [+] #[MmgG ]  /dev/VG_name/LV_name  
resize2fs       /dev/VG_name/lv_name
lvresize   -r  -l   +100%FREE  /dev/VG_name/LV_name 

缩减

umount    /dev/VG_NAME/LV_name
e2fsck  -f  /dev/VG-name/LV_NAME
fsck  -f /dev/vg0/lv0 #ext系列文件系统需要做这一步,我们是xfs,忽略即可
resize2fs    /dev/VG_name/LV_NAME
lvreduce    -L  [-]  #[mMgG]    /dev/VG_name/LV_name
mount 

跨主机迁移卷组
    源计算机上 
       1 在旧系统中,umount所有卷组上的逻辑卷 
       2 禁用卷组
         vgchange   -a  n vg0
         lvdisplay
       3 导出卷组
       vgexport   vg0 
       pvscan  
       vgdisplay 
       拆下旧硬盘
       目标主机
       4 在新系统中安装旧硬盘  并导入卷组:vgimport vg0 
        5 vgchange –ay vg0  启用 
        6 mount所有卷组上的逻辑卷 
        
  用LVM快照 
  
  为现有逻辑卷创建快照 
  lvcreate -l 64 -s -n data-snapshot -p r /dev/vg0/data 
  挂载快照
   mkdir  -p  /mnt/snap 
   mount -o ro /dev/vg0/data-snapshot   /mnt/snap 
  
       
   恢复快照     
    umount /dev/vg0/data-snapshot  
    umount /dev/vg0/data
    lvconvert --merge /dev/vg0/data-snapshot 
         
    删除快照
    umount  /mnt/databackup 
    lvremove  /dev/vg0/databackup 
    
    

Guess you like

Origin www.cnblogs.com/g2thend/p/11621040.html