• centos 格式化硬盘并挂载,添加重启后生效


    [root@cloud /]# passwd
    更改用户 root 的密码 。
    新的 密码:
    重新输入新的 密码:
    passwd: 所有的身份验证令牌已经成功更新。
    [root@cloud /]# fdisk
    
    Usage:
     fdisk [options] <disk>    change partition table
     fdisk [options] -l <disk> list partition table(s)
     fdisk -s <partition>      give partition size(s) in blocks
    
    Options:
     -b <size>                 sector size (512, 1024, 2048 or 4096)
     -c                        switch off DOS-compatible mode
     -h                        print help
     -u <size>                 give sizes in sectors instead of cylinders
     -v                        print version
     -C <number>               specify the number of cylinders
     -H <number>               specify the number of heads
     -S <number>               specify the number of sectors per track
    
    [root@cloud /]# fdisk -l
    
    Disk /dev/sda: 10.7 GB, 10737418240 bytes
    255 heads, 63 sectors/track, 1305 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: 0x00073ffb
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          64      512000   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              64        1306     9972736   8e  Linux LVM
    
    Disk /dev/sdb: 53.7 GB, 53687091200 bytes
    255 heads, 63 sectors/track, 6527 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
    
    
    Disk /dev/mapper/vg_cloud-lv_root: 8095 MB, 8095006720 bytes
    255 heads, 63 sectors/track, 984 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
    
    
    Disk /dev/mapper/vg_cloud-lv_swap: 2113 MB, 2113929216 bytes
    255 heads, 63 sectors/track, 257 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@cloud /]# df -h
    文件系统              容量  已用  可用 已用%% 挂载点
    /dev/mapper/vg_cloud-lv_root
                          7.5G  3.5G  3.7G  49% /
    tmpfs                 503M   72K  503M   1% /dev/shm
    /dev/sda1             485M   32M  428M   7% /boot
    [root@cloud /]# 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 0x6f476ca3.
    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): 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
       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)
    1
    Invalid partition number for type `1'
    Command action
       e   extended
       p   primary partition (1-4)
    p
    Partition number (1-4): 1
    First cylinder (1-6527, default 1): 
    Using default value 1
    Last cylinder, +cylinders or +size{K,M,G} (1-6527, default 6527): 
    Using default value 6527
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@cloud /]# fdisk -l
    
    Disk /dev/sda: 10.7 GB, 10737418240 bytes
    255 heads, 63 sectors/track, 1305 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: 0x00073ffb
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          64      512000   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              64        1306     9972736   8e  Linux LVM
    
    Disk /dev/sdb: 53.7 GB, 53687091200 bytes
    255 heads, 63 sectors/track, 6527 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: 0x6f476ca3
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1               1        6527    52428096   83  Linux
    
    Disk /dev/mapper/vg_cloud-lv_root: 8095 MB, 8095006720 bytes
    255 heads, 63 sectors/track, 984 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
    
    
    Disk /dev/mapper/vg_cloud-lv_swap: 2113 MB, 2113929216 bytes
    255 heads, 63 sectors/track, 257 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@cloud /]# 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
    3276800 inodes, 13107024 blocks
    655351 blocks (5.00%) reserved for the super user
    第一个数据块=0
    Maximum filesystem blocks=0
    400 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, 7962624, 11239424
    
    正在写入inode表: 完成                            
    Creating journal (32768 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@cloud /]# ls
    bin   dev  home  lost+found  media2  mnt  opt   root  selinux  sys  usr
    boot  etc  lib   media       misc    net  proc  sbin  srv      tmp  var
    [root@cloud /]# cd home
    [root@cloud home]# ls
    [root@cloud home]# ls -a
    .  ..
    [root@cloud home]# cd ..
    [root@cloud /]# mount /dev/sdb1 /home/
    [root@cloud /]# df -h
    文件系统              容量  已用  可用 已用%% 挂载点
    /dev/mapper/vg_cloud-lv_root
                          7.5G  3.4G  3.7G  48% /
    tmpfs                 503M   72K  503M   1% /dev/shm
    /dev/sda1             485M   32M  428M   7% /boot
    /dev/sdb1              50G  180M   47G   1% /home
    [root@cloud /]# echo "/dev/sdb1 /home ext3 defaults 1 1" >> /etc/fstab
    [root@cloud /]# reboot
    
    Broadcast message from root@cloud
            (/dev/pts/0) at 21:03 ...
    
    The system is going down for reboot NOW!

    首先修改密码:passwd

    查看磁盘信息:df -h

    磁盘分区:fdisk

    格式化硬盘:mkfs

    挂载:mount

    使挂载重启后生效:echo "/dev/sdb1 /home ext3 defaults 1 1" >> /etc/fstab

  • 相关阅读:
    什么是“泛在电力物联网”?要建一个什么样的泛在电力物联网?
    基于混合云雾计算的物联网架构
    探索 | “中医+AI”会诊电力设备故障
    泛在电力物联网有项核心技术 你听过没有?
    国网做泛在电力物联网的初衷是什么?如何参与?
    泛在电力物联网技术及战略解读:一个战略 两个领域 三个阶段
    构建“泛在电力物联网”成为国网当前最紧迫、最重要的任务
    如何解决分布式日志exceptionless的写入瓶颈
    SQL 查找是否"存在",别再 count 了,很耗费时间的
    abp vnext 微服务-基于Exceptionless实现分布式日志记录
  • 原文地址:https://www.cnblogs.com/walter371/p/4106742.html
Copyright © 2020-2023  润新知