澳门新萄京8522Linux磁盘自动挂载

Disk /dev/sdb:107.3 GB, 107374182400 bytes
255 heads, 63sectors/track, 13054 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes

a.txt b.txt lost+found                                  使用vi
a.txt进行写测量检验

正如好的做法应该是:在保存原硬盘的功底上,给服务器增多新的硬盘。

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *          1          13      104391  83  Linux
/dev/sda2              14        2563  20482875  83  Linux
/dev/sda3            2564        2824    2096482+  82  Linux swap /
Solaris

[root@localhost mnt]#umount /dev/sdb1

回想磁盘分区时的注意事项:

能够查看磁盘的新闻。
[root@localhost/]# df -h
文件系统体积已用可用已用% 挂载点
/dev/sda2              19G  3.1G  15G  18% /
/dev/sda1              99M  12M  82M  13% /boot
tmpfs                500M    0 500M  0% /dev/shm
/dev/hdc              4.1G  4.1G    0 100% /media/RHEL_5.9 x86_64
DVD
/dev/sdb1              46G  181M  44G  1% /home

7.重启linux系统,检查挂载情状

  • 主分区和扩大分区总量不可能超越4个。
  • 恢宏分区最七只可以有一个
  • 庞大分区不可能直接存取数据

新建/home目录,将/dev/sdb1挂载到/home目录下,将/home原本的数码复制回新建的/home目录中,鲜明数据总体过来后删除/home1目录。
[root@localhost/]# mkdir /home
[root@localhost/]# mount /dev/sdb1 /home
[root@localhost/]# cp -rpf /home1/* /home
[root@localhost/]# ls /home
jacky  lily lost+found  tom

[root@localhost mnt]# mount /dev/sdb1 /mnt/sdb1    
将磁盘sdb挂载到系统中

    Hex code (type L to list codes): 82
    Changed system type of partition 2 to 82 (Linux swap / Solaris)

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@joe dev]# fdisk 

/dev/
    sdb

    WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').

    Command (m for help): p

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1        1000     8032468+  83  Linux
    /dev/sdb2            1001        1100      803250  

 82 Linux swap /
     Solaris
    /dev/sdb3            1101        2610    12129075    5  Extended
    /dev/sdb5            1101        1500     3212968+  83  Linux
    /dev/sdb6            1501        2610     8916043+  83  Linux

    Command (m for help): q

    [root@joe dev]# mkswap 

/dev/sdb2
        //设置交换区
    Setting up swapspace version 1, size = 803244 KiB
    no label, UUID=c7d31434-4013-4bbb-b68e-29b501934377
    [root@joe dev]# swapon 

/dev/sdb2
        //开启交换区
    [root@joe dev]# free
                 total       used       free     shared    buffers     cached
    Mem:       1030612     132468     898144          0      13612      51388
    -/+ buffers/cache:      67468     963144
    Swap:      

2851232 0 2851232

    [root@joe dev]# swapoff 

/dev/sdb2
        //关闭交换区
    [root@joe dev]#

将/home分区中的内容移动到/home第11中学。
[root@localhost~]# mv /home /home1
[root@localhost/]# ls /home1/
jacky  lily tom

/dev/sdb1  3288944  71328   3050540     3%       /mnt/sdb1

  1. 将虚拟机关机(poweroff)。(当然,也可以有服务器的主板补助热插拔的。能够带电连日来新硬盘。)
  2. 设想机设置->下面包车型大巴“增多”->类型选取“硬盘”->下一步->选用硬盘类型(暗中同意的(SCSI)就好)->制造多个新的设想机硬盘(下一步)->设置磁盘最大值;(没什么特殊供给,基本都以下一步,最终一步OK)。
  3. 重启Linux系统,使用fdisk
    -l//显示每种硬盘的分区列表(新扩展加的硬盘是尚未分区表的)能够看来Disk
    /dev/sdb:和Disk /dev/sda:2块硬盘,以及sda的分区表,未有sdb的分区表。
  4. 先选择MBCRUISER分区方式为sdb分区。

    [root@joe dev]# 
    

    fdisk
    /dev/sdb

        //进入分区模式
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0x9ce83f46.
    Changes will remain in memory only, until you decide to write them.
    After that, of course, the previous content won't be recoverable.
    

    Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

    WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
    switch off the mode (command ‘c’) and change display units to
    sectors (command ‘u’).

    Command (m for help):

    style=”background-color: #ffc000;”>m

       //查看帮助
    Command action
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition    //删除一个分区
       l   list known partition types
       m   print this menu
       n   add a new partition    //添加新的分区
       o   create a new empty DOS partition table
       p   print the partition table    //打印分区表
       q   quit without saving changes    //取消保存并退出
       s   create a new empty Sun disklabel
       t   change a partition's system id    //修改分区的系统ID
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit        //写分区表并退出
       x   extra functionality (experts only)
    

    Command (m for help): n
    Command action
    e extended //扩张分区
    p primary partition (1-4)//主分区
    p
    Partition number (1-4):

    style=”color: #800080;”>1

    First cylinder (1-2610, default 1): //扇区的界定(1-2610),暗中认可初步1,直接回车则使用暗许数值
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): 500M

    Command (m for help): p

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9ce83f46

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 500 4016218+ 83 Linux //分配好的主分区1
    //加多第叁个分区
    Command (m for help): n
    Command action
    e extended
    p primary partition (1-4)
    p
    Partition number (1-4):
    Value out of range.
    Partition number (1-4): 2
    First cylinder (501-2610, default 501):
    Using default value 501
    Last cylinder, +cylinders or +size{K,M,G} (501-2610, default 2610): 500M
    Value out of range.
    Last cylinder, +cylinders or +size{K,M,G} (501-2610, default 2610):
    Using default value 2610

    Command (m for help): p

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065
    512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9ce83f46

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 500 4016218+ 83 Linux
    /dev/sdb2 501 2610 16948575 83 Linux //第二个分区
    //由于分配不适于主观愿望,想删除分区
    Command (m for help): d
    Partition number (1-4):

    style=”background-color: #ffc000;”>2

          //分区编号
    

    Command (m for help): p

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9ce83f46

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 500 4016218+ 83 Linux //第二个分区已经去除

    Command (m for help): n
    Command action
    e extended
    p primary partition (1-4)
    p
    Partition number (1-4):

    style=”background-color: #ffc000;”>2

    First cylinder (501-2610, default 501):
    Using default value 501
    Last cylinder, +cylinders or +size{K,M,G} (501-2610, default 2610): 1000

    Command (m for help): p

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9ce83f46

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 500 4016218+ 83 Linux
    /dev/sdb2 501 1000 4016250 83 Linux

    Command (m for help): n
    Command action
    e extended
    p primary partition (1-4)
    e //建设构造增加分区
    Partition number (1-4):

    style=”color: #800080;”> style=”text-decoration: underline;”>3

    First cylinder (1001-2610, default 1001):
    Using default value 1001
    Last cylinder, +cylinders or +size{K,M,G} (1001-2610, default 2610):
    Using default value 2610

    Command (m for help): p

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9ce83f46

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 500 4016218+ 83 Linux
    /dev/sdb2 501 1000 4016250 83 Linux
    /dev/sdb3 1001 2610 12932325 5 Extended

    Command (m for help): n
    Command action
    l logical (

    style=”color: #800080;”>5 or over)

        //此时扩展分区e没有了,说明MBR只能有一个扩展分区,接下来是逻辑分区
       p   primary partition (1-4)
    l
    First cylinder (1001-2610, default 1001): 
    Using default value 1001
    Last cylinder, +cylinders or +size{K,M,G} (1001-2610, default 2610): 1500
    

    Command (m for help): p

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9ce83f46

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 500 4016218+ 83 Linux
    /dev/sdb2 501 一千 4016250 83 Linux
    /dev/sdb3 1001 2610 12932325 5 Extended
    /dev/sdb5 1001 1500 4016218+ 83 Linux //逻辑分区是从5上马的,1-4只好是主分区和增添分区的数码

    Command (m for help): n
    Command action
    l logical (5 or over)
    p primary partition (1-4)
    l
    First cylinder (1501-2610, default 1501):
    Using default value 1501
    Last cylinder, +cylinders or +size{K,M,G} (1501-2610, default 2610):
    Using default value 2610

    Command (m for help): p

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065
    512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9ce83f46

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 500 4016218+ 83 Linux
    /dev/sdb2 501 1000 4016250 83 Linux
    /dev/sdb3 1001 2610 12932325 5 Extended
    /dev/sdb5 1001 1500 4016218+ 83 Linux
    /dev/sdb6 1501 2610 8916043+ 83 Linux

    Command (m for help):

    style=”background-color: #ffc000;”>w //保存写

    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@joe dev]# fdisk

    l
    

    Disk

    /dev/sdb

    : 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x9ce83f46
    

    Device Boot Start End Blocks Id System
    /dev/sdb1 1 500 4016218+ 83 Linux
    /dev/sdb2 501 1000 4016250 83 Linux
    /dev/sdb3 1001 2610 12932325 5 Extended
    /dev/sdb5 1001 1500 4016218+ 83 Linux
    /dev/sdb6 1501 2610 8916043+ 83 Linux

    Disk

    /dev/sda

    : 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x000a030a
    

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 26 204800 83 Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2 26 281 2048000 82 Linux swap / Solaris
    Partition 2 does not end on cylinder boundary.
    /dev/sda3 281 536 2048000 83 Linux
    Partition 3 does not end on cylinder boundary.
    /dev/sda4 536 2611 16669696 5 Extended
    /dev/sda5 536 2611 16668672 83 Linux

  5. 接纳GPT分区情势分区(同期GPT的分区工具parted也能够MBCR-V分区)

    [root@joe dev]# parted
    GNU Parted 2.1
    使用 
    

    /dev/sda

        //注意正在使用的是sda
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) print all                                                        
    Model: VMware, VMware Virtual S (scsi)
    Disk /dev/sda: 21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    
    Number  Start   End     Size    Type      File system     标志
     1      1049kB  211MB   210MB   primary   ext4            启动
     2      211MB   2308MB  2097MB  primary   linux-swap(v1)
     3      2308MB  4405MB  2097MB  primary   ext4
     4      4405MB  21.5GB  17.1GB  extended
     5      4406MB  21.5GB  17.1GB  logical   ext4
    

Disk /dev/sdbdoesn’t contain a valid partition table

Command (m for help): p                               p:print the partintion table


Command(m for help): p

[root@localhost sdb1]#
ls                              实行写文件测验,检查是或不是能够对磁盘举行读写(是或不是格式化)

为虚构机加多硬盘

现新扩展一块磁盘。用fdisk命令查看磁盘状态。
[root@localhost~]# fdisk -l
Disk /dev/sda: 85.8GB, 85899345920 bytes
255 heads, 63sectors/track, 10443 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes

Units = cylinders of 16065 * 512 = 8225280 bytes

基本功命令

更多RedHat有关消息见RedHat 专项论题页面 http://www.linuxidc.com/topicnews.aspx?tid=10

1.先是查看系统中磁盘音信,并规定是还是不是必要分区。


从/dev/sdb中分出50G用来存放用户家目录数据。
[root@localhost~]# fdisk /dev/sdb
Command(m for help): n
Commandaction
  e  extended
  p  primary partition (1-4)
p
Partitionnumber (1-4): 1
Firstcylinder (1-13054, default 1): 1
Lastcylinder or +size or +sizeM or +sizeK (1-13054, default 13054): +50G

/dev/sda1 * 14 1044 8281507+ 83
Linux       

对/home分区拓展搬迁。
/home存放普通用户的家目录,系统中所建普通用户在访问服务器时文件存放在和煦的家目录中,当用户好些个据量过大磁盘分区缺乏使用,供给扩大磁盘,将/home分区迁徙到新添磁盘中,及普通用户文件将存放在到新添磁盘中。
新建八个普通用户,查看/home下的用户家目录。
[root@localhost~]# useradd jacky
[root@localhost~]# useradd tom
[root@localhost~]# useradd lily
[root@localhost~]# ls /home/
jacky  lily tom

Partition number (1-4): 3                               接纳分区数。

  • df查看磁盘分区使用处境
    1. -l //仅突显本地球磁性盘(暗中认可)
    2. -a //展现全部文件系统的磁盘使用情形,包涵诸如/proc/
    3. -h //以1024进制总计最合适的单位呈现磁盘容积
    4. -H //以一千进制总括最合适的单位出示磁盘体量
    5. -t //展现内定项目文件系统的磁盘分区
    6. -T //显示磁盘分区类型
    7. -x //不显示钦定项目文件系统的磁盘分区
  • du总括磁盘上的文件大小
    1. -b //以byte为单位计算文件
    2. -k //以KB为单位统计文件
    3. -m //以MB为单位计算文件
    4. -h //以1024进制计算最合适的单位出示磁盘体积
    5. -H //以1000进制总计最合适的单位呈现磁盘体积
    6. -s //总结内定指标
  • 常用命令
    1. df -lhT
    2. df -lhT -t ext4(分区类型)
    3. df -lhT -x ext4
    4. du -s [点名目录]
    5. du -sb *.zip //模糊相称
    6. du -sm *.zip
    7. du -sh *.zip

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1        6080  48837568+  83  Linux
Command(m for help): w

[root@localhost ~]# fdisk
–l                              使用fdisk查看磁盘分区情状


对磁盘举行格式化。两条命令完毕的职能同样,都以对磁盘进行格式化。
[root@localhost~]# mkfs.ext3 /dev/sdb1
[root@localhost~]# mkfs -t ext3 /dev/sdb1

如上所示,将新建的磁盘的八个分区顺遂挂载到系统中。

  • Linux系统中硬件装置都以以文件的花样存在于根目录下的Dev目录下。
  • 硬件装置都以有Linux系统自动识别的。
  • 充裕的新硬盘,必须开始展览分区、格式化、挂载后本事运用。
  • MBKoleos分区方式:主分区不超越4个,单个分区体积最大为2TB
  • GPT分区方式:主分区个数“大概”未有范围,单个分区容积“大概”未有界定。GPT分区中,最多能够帮衬130个主分区,且每种分区的大小突破了MBEnclave分区的2TB的限量,最大为18EB=18432PB=18874368TB。缺点是GPT的主分区中,不符合安装B86框架结构的体系。

Disk/dev/sdb: 107.3 GB, 107374182400 bytes
255heads, 63 sectors/track, 13054 cylinders
Units =cylinders of 16065 * 512 = 8225280 bytes

5.测试准确后将其卸载

那篇博文首要计算了Linux磁盘的一部分操作,首即使硬盘的加载,分区(MB奥迪Q5分区和GPT分区),分区的挂载,以及swap分区的加载设置。

澳门新萄京8522 1

Units = cylinders of 16065 * 512 = 8225280 bytes

  1. 分区完今后,正是格式化和挂载分区了。也正是设置文件系统。在此处须要小心以下内容:MBEvoque分区不得不格式化主分区和扩丰硕区,逻辑分无不能够格式化
    GPT分区,在格式化以后,只可以选用parted 的print查看格式结果
    挂载分区:分区暗中认可的挂载目录/mnt目录挂载点必须存在。

    [root@joe dev]#
    

    ls -l /dev/sdb*

    brw-rw----. 1 root disk 8, 16 5月   7 01:18 /dev/sdb
    brw-rw----. 1 root disk 8, 17 5月   7 01:18 /dev/sdb1
    brw-rw----. 1 root disk 8, 18 5月   7 01:18 /dev/sdb2
    brw-rw----. 1 root disk 8, 19 5月   7 01:18 /dev/sdb3
    brw-rw----. 1 root disk 8, 21 5月   7 01:18 /dev/sdb5
    brw-rw----. 1 root disk 8, 22 5月   7 01:18 /dev/sdb6
    [root@joe dev]# mkfs.ext3 
    

    /dev/sdb1

            //第一种设置方式
    mke2fs 1.41.12 (17-May-2010)
    文件系统标签=
    操作系统:Linux
    块大小=4096 (log=2)
    分块大小=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    502944 inodes, 2008117 blocks
    100405 blocks (5.00%) reserved for the super user
    第一个数据块=0
    Maximum filesystem blocks=2059403264
    62 block groups
    32768 blocks per group, 32768 fragments per group
    8112 inodes per group
    Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
    
    正在写入inode表: 完成                            
    Creating journal (32768 blocks): 完成
    Writing superblocks and filesystem accounting information: 完成
    
    This filesystem will be automatically checked every 23 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    [root@joe dev]# mkfs 
    

    -t ext4 /dev/sdb2

            //第二种方法
    mke2fs 1.41.12 (17-May-2010)
    文件系统标签=
    操作系统:Linux
    块大小=4096 (log=2)
    分块大小=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    50288 inodes, 200812 blocks
    10040 blocks (5.00%) reserved for the super user
    第一个数据块=0
    Maximum filesystem blocks=209715200
    7 block groups
    32768 blocks per group, 32768 fragments per group
    7184 inodes per group
    Superblock backups stored on blocks: 
        32768, 98304, 163840
    
    正在写入inode表: 完成                            
    Creating journal (4096 blocks): 完成
    Writing superblocks and filesystem accounting information: 完成
    
    This filesystem will be automatically checked every 26 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    [root@joe dev]# 
    

    mkdir -p /mnt/joetest

        //首先建立挂载点
    [root@joe dev]# 
    

    mount /dev/sdb1 /mnt/joetest/

            //挂载分区
    [root@joe dev]# 
    

    umount /mnt/joetest/

                //卸载挂载点
    
    上面这中挂载方式是临时的,永久性的应该如下:
    vim 
    
    • /etc/
      fstab
      在最后插入一行

    /dev/sdb1 /mnt/imooc ext3
    default 0 0

    设备名称    挂载点    文件系统类型
    保存退出即可
    
  2. swap调换分区(步骤为:建设构造贰个平淡无奇的Linux分区,修改分区类型的16进制编码,格式化调换分区,启用交流分区。

    [root@joe dev]# 
    

    fdisk /dev/

    sdb
    
    WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
    WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').
    
    Command (m for help): p
    
    Disk /dev/sdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1        1000     8032468+  83  Linux
    /dev/sdb2            1001        1100      803250   83  Linux
    /dev/sdb3            1101        2610    12129075    5  Extended
    /dev/sdb5            1101        1500     3212968+  83  Linux
    /dev/sdb6            1501        2610     8916043+  83  Linux
    
    Command (m for help): t
    Partition number (1-6): 
    

    2

           //修改ID
    Hex code (type L to list codes): L
    
     0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
     1  FAT12           39  Plan 9          
    

    82 Linux swap

     / So c1  DRDOS/sec (FAT-
     2  XENIX root      3c  PartitionMagic  
    

    83 Linux

               c4  DRDOS/sec (FAT-
     3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
    

[root@localhost mnt]# vi /etc/fstab

当硬盘空间消耗殆尽时怎么做?

如上所示,系统中有两块磁盘sda、sdb,并提醒sdb未包涵分区表,供给将其开始展览分区操作。

    Model: VMware, VMware Virtual S (scsi)
    Disk 

/dev/sdb:
     21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos    //sdb的应该是我们需要的gpt

    Number  Start  End  Size  Type  File system  标志


    警告: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
    错误: /dev/sr0: unrecognised disk label                                   

    (parted) 

select /dev/sdb
          //选择sdb                                            
    使用 /dev/sdb
    (parted) mkpart     //如果不进行gpt的选择设置,直接mkpart那么我们还是使用的MBR模式                                                      
    分区类型?  primary/主分区/extended/扩展分区? primary                     
    文件系统类型?  [ext2]? ^Z
    --------------------------------------------------------------------------------------------------
    (parted) 

select /dev/
    sdb                                                  
    使用 /dev/sdb
    (parted) mklabel gpt                                                      
    警告: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you
    want to continue?
    是/Yes/否/No? yes
    (parted) print all                                                        
    Model: VMware, VMware Virtual S (scsi)
    Disk 

/dev/sda:
     21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos

    Number  Start   End     Size    Type      File system     标志
     1      1049kB  211MB   210MB   primary   ext4            启动
     2      211MB   2308MB  2097MB  primary   linux-swap(v1)
     3      2308MB  4405MB  2097MB  primary   ext4
     4      4405MB  21.5GB  17.1GB  extended
     5      4406MB  21.5GB  17.1GB  logical   ext4


    Model: VMware, VMware Virtual S (scsi)
    Disk 

/dev/sdb:
     21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Number  Start  End  Size  File system  Name  标志


    警告: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
    错误: /dev/sr0: unrecognised disk label                                   

    (parted) mkpart                                                           
    分区名称?  []? test1                                                     
    文件系统类型?  [ext2]? ext4
    起始点?

1 
               //以1开始,默认单位是M  unit GB 指定为GB为单位                                               
    结束点? 1000M                                                           
    (parted) print                                                            
    Model: VMware, VMware Virtual S (scsi)
    Disk /dev/sdb: 21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Number  Start   End     Size   File system  Name   标志
     1      1049kB  1000MB  999MB               test1

    (parted)

rm 1
         //删除分区                                                        
    (parted) print                                                            
    Model: VMware, VMware Virtual S (scsi)
    Disk /dev/sdb: 21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Number  Start  End  Size  File system  Name  标志

    (parted) mkpart                                                           
    分区名称?  []? test1                                                     
    文件系统类型?  [ext2]? ext4                                            
    起始点?0       //以0开始,出现了警告,这里是字节对齐的原因造成的,所以一般为了避免警告,我们不以0开始。                                                        
    结束点? 1000M
    警告: The resulting partition is not properly aligned for best performance.
    忽略/Ignore/放弃/Cancel? cancel                                           
    (parted) mkpart
    分区名称?  []? test1                                                     
    文件系统类型?  [ext2]? ext4                                              
    起始点?1                                                                
    结束点?1000M                                                            
    (parted) print                                                            
    Model: VMware, VMware Virtual S (scsi)
    Disk /dev/sdb: 21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Number  Start   End     Size   File system  Name   标志
     1      1049kB  1000MB  999MB               test1

    (parted) mkpart                                                           
    分区名称?  []? test2                                                     
    文件系统类型?  [ext2]? ext4                                              
    起始点? 1000M                                                            
    结束点? 1500M                                                            
    (parted) print
    Model: VMware, VMware Virtual S (scsi)
    Disk /dev/sdb: 21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Number  Start   End     Size   File system  Name   标志
     1      1049kB  1000MB  999MB               test1
     2      1000MB  1500MB  500MB               test2
    //上面是交互模式,下面是命令模式
    (parted) mkpart test3 

1500 3000
             //使用一条命令直接搞定 分区名 起始位 结束位                                  
    警告: The resulting partition is not properly aligned for best performance.    //出现分区的原因是起始的1500和上次结束的1500重叠了。
    忽略/Ignore/放弃/Cancel? cancel         
    (parted) mkpart test3 1501M 1700M                                         
    (parted) mkpart test4 1701M 1800M                                        
    (parted) mkpart test5 1801M 1900M                                        
    (parted) print                                                            
    Model: VMware, VMware Virtual S (scsi)
    Disk /dev/sdb: 21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt

    Number  Start   End     Size    File system  Name   标志
     1      1049kB  1000MB  999MB                test1
     2      1000MB  1500MB  500MB                test2
     3      1501MB  1700MB  199MB                test3
     4      1701MB  1800MB  99.6MB               test4
     5      1801MB  1900MB  98.6MB               test5

    (parted) 

rm 5

    (parted) quit

devpts /dev/pts devpts gid=5,mode=620 0 0

3.将分区好的磁盘举行格式化操作

proc /proc proc defaults 0 0

/dev/sdb2 /mnt/sdb2 ext3 defaults 0 0

6.修改fstab文件,正如所示:

p primary partition (1-4)

[root@localhost ~]# mke2fs -j
/dev/sdb1
                将磁盘sdb1格式化为ext3文件系统。

/dev/sdb1 /mnt/sdb1 ext3 defaults 0 0

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图