zoukankan      html  css  js  c++  java
  • DiskManage_磁盘管理

    /*----------------------------磁盘管理-------------------------------------------*/

    -----'UUID'----(Universally Unique Identifier)'通用唯一识别码'

    1.UUID 的目的,是让'分布式系统中的所有元素',都能有'唯一的辨识'资讯,而不需要透过中央控制端来做辨识资讯的指定。.

    2.以U盘为例,假如有一个U盘分了三个区,每个区都会分配有一个UUID,这个'UUID是记录在U盘上的',
    而不是在某一个系统中,这样就不会出现U盘在不同的系统中设备名不同的问题。

    ----查看UUID && LABEL 命令

    'blkid'--command-line utility to locate/print block device attributes('查询块设备属性'的命令行应用程序)

    1.blkid //查看/dev/下所有块设备的详细属性

    2.blkid /dev/sda1 //查看指定设备的属性

    3.blkid -s [TYPE|UUID|LABEL] //产看块设备的UUID|TYPE|LABEL

    '/*不要在虚拟机里执行 blkid /dev/* 命令,虚拟机会挂起fedora,并导致网络断开*/'


    -------'UUID' && 'LABEL' 的应用--------

    '注':This will make the system more robust(强健的): adding or removing a SCSI disk
    changes the disk device name but not the filesystem volume label.

    ----改变LABEL名称:

    1.e2label /dev/hda1 /boot //为/dev/hda1设置卷标为'/boot'


    ----在mount 命令中使用 LABEL/UUID

    1.mount LABEL=/boot1 /boot
    mount -L /boot /mnt/smbLung/

    2.mount UUID="51f7e9a4-5154-4e29-a7a6-208417290b85" /mnt/
    mount -U 7826f66e-4fdc-4ab8-9d95-6a1ddb1c7eaa /mnt/smbJon/




    /**Files:*/

    '/etc/fstab file system table

    '/etc/mtab table of mounted file systems //通过mount查到的fs


    ----在 /etc/fstab 中使用 LABEL/UUID

    1.LABEL=/ / ext3 defaults 1 1

    2.LABEL=/boot1 /boot ext3 defaults 1 2

    3.UUID=e61f4197-5f00-4f4f-917c-290922a85339 /usr ext3 defaults 1 12




    *******************磁盘管理***********************************

    --------文件

    1./proc/filesystems // a list of filesystem types to try

    2./proc/partitions //分区表;没有fdisk -l 返回的信息完整

    3./etc/fstab //file system table


    -------图形化挂载工具

    1.usermount //root用户执行该命令

    -------命令

    --------fdisk(partition table manipulator for Linux:'Linux的分区表操作器')-------------------------

    注:'a'.It understands 'DOS-type'partition tables and 'BSD- or SUN-type disklabels.'

    'b'.fdisk does not understand GUID partition tables (GPTs) and it is 'not'
    designed for 'large partitions'. In these cases, use the more advanced
    GNU 'parted'(8)
    /* fdisk 不适用于大分区,此时应用parted命令*/

    0.fdisk -l [device] //列出指定设备的分区表;If no devices are given,
    //those mentioned in /proc/partitions (if that exists) are used


    1.A sync() are performed before exiting when the partition table has been updated.
    Note that both the kernel and the disk hardware may buffer data.

    翻译:在修改 分区表 后,推荐使用sync() 命令,将缓冲区的数据写入磁盘。
    内核 和 磁盘 都可能 缓冲数据

    2.For best results, you should always use an 'OS-specific partition table program'

    a.'make DOS partitions' with the 'DOS FDISK program'
    b.'Linux partitions ' with the 'Linux fdisk program'




    ------------------df - report file system disk space usage------------------- //查看磁盘使用信息

    1.df -h //以human-readable格式列出


    ------------------挂载命令

    mount -t vfat /dev/sdb1 /mnt/usb //-t指定文件系统

    mount -o iocharset=cp936 /dev/sdb1 /mnt/usb //显示Window下的中文字符

    mount -a //将fstab设置的没有使用noauto选项的所有文件系统按照指定方式挂载

    ------------------格式化磁盘

    /***In order to make it possible to treat all types in a uniform way,
    mount will execute the program /sbin/mount.TYPE (if that exists)
    when called with type TYPE.
    ***/

    mkfs -t ext3 /dev/hd4 //格式化
    mkfs.ext3 /dev/hd4

    mkfs -t vfat /dev/hd3
    mkfs.vfat /dev/hd3


    ---------tune2fs:调整可调的文件系统参数 on ext2/3/4 fs.

    1.tune2fs -l /dev/sda1 //列出文件系统 现在的各项参数



    ---------dd:convert and copy a file:转换并且拷贝文件

    1.dd if=/dev/hdx of=/dev/hdy //将本地的/dev/hdx整盘备份到/dev/hdy

    ------------

    2.dd if=/dev/hdx of=/path/to/image //将/dev/hdx全盘数据备份到指定路径的image文件:

    3.dd if=/path/to/image of=/dev/hdx //将备份文件恢复到指定盘:、

    ------------

    4.dd if=/dev/hdx | gzip >/path/to/image.gz //备份/dev/hdx全盘数据,并利用gzip工具进行压缩,保存到指定路径:

    5.gzip -dc /path/to/image.gz | dd of=/dev/hdx //将压缩的备份文件恢复到指定盘 :

    ----'备份MBR'

    1.dd if=/dev/hdx of=/path/to/image count=1 bs=512 //备份磁盘开始的512Byte大小的MBR信息到指定文件:

    2.dd if=/path/to/image of=/dev/hdx //将备份的MBR信息写到磁盘开始部分:

    -----'.拷贝内存资料到硬盘'

    1.dd if=/dev/mem of=/root/mem.bin bs=1024 //将内存里的数据拷贝到root目录下的mem.bin文件:

    -----'从光盘拷贝iso镜像

    1.dd if=/dev/cdrom of=/root/cd.iso //拷贝光盘数据到root文件夹下,并保存为cd.iso文件:

    -----'增加Swap分区文件大小

    1.dd if=/dev/zero of=swapfile bs=1M count=100 //创建100M空文件swapfile

    2.mkswap swapfile

    3.swapon swapfile //激活

    4.swapon -s //查看所有swap文件或分区

    5.mount -a (写入fstab文件) //重启时由rc.sysinit初始化脚本激活,以后启动系统即可自动挂载


    -----'销毁磁盘数据

    1.dd if=/dev/urandom of=/dev/hda1 //利用随机的数据填充硬盘:
    //在某些必要的场合可以用来销毁数据。执行此操作以后,/dev/hda1将无法挂载,创建和拷贝操作无法执行。

    -----'修复硬盘

    /*当硬盘较长时间(比如一两年年)放置不使用后,磁盘上会产生magnetic flux point。当磁头读到
    这些区域时会遇到困难,并可能导致I/O错误。当这种情况影响到硬盘的第一个扇区时,可能导致
    硬盘报废。下面的命令有可能使这些数据起死回生。且这个过程是安全,高效的。*/

    1.dd if=/dev/sda of=/dev/sda



    ------'/dev/zero':特殊c文件,当读取它时,它将提供充足的 null characters (ASCII NULL, 0x00; not ASCII character "digit zero", "0", 0x30)

    ----用途

    1.provide a character stream for overwriting information.

    # Initialise partition (important note: trying out this command will eradicate
    # any files that were on the partition, make sure you have a backup of any important data.)

    dd if=/dev/zero of=/dev/hda7

    2.Another might be to generate a clean file of a certain size.

    # Create a large empty file called 'foobar'
    dd if=/dev/zero of=foobar count=1000 bs=1000

    3.Using mmap to map /dev/zero to RAM is the BSD way of implementing shared memory.
    我在IBM工作,可以为大家内部推荐IBM各种职位 IBM全球职位尽在以下链接(请在浏览器中打开,QQ/微信 会阻止): http://ibmreferrals.com/ 很乐意为感兴趣的小伙伴分享:我的面试经验^_^ 如需咨询,请邮件发送以下邮箱,有问必回 1026096425@qq.com
  • 相关阅读:
    Django rest framework Pagination(分页)
    Vue的mixin的一点使用(table的头部sticky的实现)
    spark streaming中维护kafka偏移量到外部介质
    spring-cloud-gateway负载普通web项目
    JdbcTemplate实体映射
    Sqoop葵花宝典
    kettle web化
    Summer Project
    Spark执行失败时的一个错误分析
    spark load data from mysql
  • 原文地址:https://www.cnblogs.com/jackydalong/p/2408781.html
Copyright © 2011-2022 走看看