• 阿里云数据盘分区并挂载


    http://help.aliyun.com/origin?helpId=271

      查看已挂在磁盘使用情况 df -h

    [root@AY121110111722e1c8917 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/xvda1             20G  1.2G   18G   6% /
    tmpfs                 245M     0  245M   0% /dev/shm

    查看磁盘,包括未挂在的,个人理解的是磁盘的个数。
    [root@AY121110111722e1c8917 ~]# fdisk -l
    
    Disk /dev/xvda: 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: 0x00073f45
    
        Device Boot      Start         End      Blocks   Id  System
    /dev/xvda1   *           1        2611    20970496   83  Linux
    
    Disk /dev/xvdb: 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
    创建分区
    [root@AY121110111722e1c8917 ~]# fdisk /dev/xvdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0x8121207b.
    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): n
    Command action
       e   extended
       p   primary partition (1-4)
    p 
    Partition number (1-4): 1
    First cylinder (1-2610, default 1): 
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): 2610
    
    Command (m for help): wq
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@AY121110111722e1c8917 ~]# 
    查看新分区
    [root@AY121110111722e1c8917 ~]# fdisk -l
    
    Disk /dev/xvda: 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: 0x00073f45
    
        Device Boot      Start         End      Blocks   Id  System
    /dev/xvda1   *           1        2611    20970496   83  Linux
    
    Disk /dev/xvdb: 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: 0x8121207b
    
        Device Boot      Start         End      Blocks   Id  System
    /dev/xvdb1               1        2610    20964793+  83  Linux
    [root@AY121110111722e1c8917 ~]# 
    格式化分区
    [root@AY121110111722e1c8917 ~]# mkfs.ext3 /dev/xvdb1 
    mke2fs 1.41.12 (17-May-2010)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    1310720 inodes, 5241198 blocks
    262059 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=4294967296
    160 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks: 
            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
            4096000
    
    Writing inode tables: done                            
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    This filesystem will be automatically checked every 29 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    [root@AY121110111722e1c8917 ~]# 

    添加新分区

      使用下列命令挂在新分区后,挂在信息会追加到/etc/fstab文件中,以后在系统重启之后不需要重新挂在,如果用mount命令挂在,系统在下次启动时不会自动挂在新分区。

    [root@AY121110111722e1c8917 ~]# echo '/dev/xvdb1 /mnt/xvdb1 ext3 defaults 0 0' >> /etc/fstab
    [root@AY121110111722e1c8917 ~]# cat /etc/fstab 
    
    #
    # /etc/fstab
    # Created by anaconda on Mon Dec 17 09:06:53 2012
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    UUID=887b0b9e-449b-414e-a11d-cd94093e3fe1 /                       ext3    defaults        1 1
    tmpfs                   /dev/shm                tmpfs   defaults        0 0
    devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
    sysfs                   /sys                    sysfs   defaults        0 0
    proc                    /proc                   proc    defaults        0 0
    xenfs                   /proc/xen               xenfs   defaults        0 0
    /dev/xvdb1              /mnt/xvdb1              ext3    defaults        0 0
    [root@AY121110111722e1c8917 ~]# 

    使/etc/fstab文件立刻生效,执行命令:

    [root@AY121110111722e1c8917 ~]# mount -a

    如果文件夹/mnt/xvdb1不存在,需要手动创建

    [root@AY121110111722e1c8917 ~]# mkdir /mnt/xvdb1

    使用df -h查看

    [root@AY121110111722e1c8917 ~]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/xvda1             20G  1.2G   18G   6% /
    tmpfs                 245M     0  245M   0% /dev/shm
    /dev/xvdb1             20G  173M   19G   1% /mnt/xvdb1
    [root@AY121110111722e1c8917 ~]# 
  • 相关阅读:
    Vue 服务器端渲染(一)
    vue笔记 介绍及安装 一
    Node.js 学习笔记 (一) 安装配置
    Java开发中的23种设计模式详解(转)
    spring-boot整合ehcache实现缓存机制
    STM32流水灯
    SD卡封转及管脚说明
    随笔分类
    函数的设计之我见
    让灵魂追得上我们疲惫的身体
  • 原文地址:https://www.cnblogs.com/grj1046/p/3235082.html
Copyright © 2020-2023  润新知