U disk partition

markdown # Partitioned hard disk repartition ## Preface I have a U disk with two partitions, 20G and 98G. Now I need to divide into four areas, 20G, 75G, 16G, 8G. ## Repartition Back up files first, and then use the following command: ``` gdisk /dev/sda ``` Then I did the following: ``` GPT fdisk (gdisk) version 1.0.5 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): d #Delete Partition number (1-4): 2 #The number of the partition to be deleted Command (? for help): n #New a partition Partition number (2-128, default 2): 2 #The number of the partition to be created First sector (34-249737182, default = 41945088) or {+-}size{KMGTP}: #Default Last sector (41945088-199231487, default = 199231487) or {+-}size{KMGTP}: +75G #Size Current type is 8300 (Linux filesystem) Hex code or GUID (L to show codes, Enter = 8300): #Default Changed type of partition to 'Linux filesystem' Command (? for help): w #Apply Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y ``` ## Format & Rename Then format it into the required file system: ``` mkfs.ext4 /dev/sda2 mkfs.ntfs /dev/sda3 mkfs.ext4 /dev/sda4 ``` You can also change your disk name: ``` fatlabel /dev/sda1 FAT32 e2label /dev/sda2 ext4 ntfslabel /dev/sda3 NTFS e2label /dev/sda4 xubuntu ``` ![](https://raw.githubusercontent.com/Baileyus/blog_img/main/udisk1.png) Completed! # 追加 1.8T 单分区大硬盘 ## 分区 查看字节数, 然后再除n个1024就得到大小是1863G, 我不分满, 分1860G ![](https://raw.githubusercontent.com/Baileyus/blog_img/main/2023-12-06_11-18.png) 按照以下命令操作: ``` sudo gdisk /dev/sda GPT fdisk (gdisk) version 1.0.8 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): d Using 1 Command (? for help): n Partition number (1-128, default 1): First sector (34-3907029134, default = 2048) or {+-}size{KMGTP}: Last sector (2048-3907029134, default = 3907029134) or {+-}size{KMGTP}: +1860G Current type is 8300 (Linux filesystem) Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem' Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to /dev/sda. The operation has completed successfully. ``` ## 格式化 用 mkfs 格式化, 因为我用需要存 Linux 和 Windows 的东西, 而且是机械硬盘, 所以选用 ntfs 使用 -f 参数快速格式化 ``` sudo mkfs.ntfs -f /dev/sda1 Cluster size has been automatically set to 4096 bytes. Creating NTFS volume structures. mkntfs completed successfully. Have a nice day. ``` 改名 Anchorage: ``` umount /dev/sda1 sudo ntfslabel /dev/sda1 Anchorage ``` Complete! # 1.8T 硬盘分区 20240117 ## 前言 上次发现 NTFS 是 Windows 的文件系统, 对Linux的支持不太友好, 例如无法包含某些特殊字符之类的, 所以把他分成了 300G EXT4 分区, 1500G NTFS 分区 ## 问题 硬盘通过 USB 线和 SATA 线, 都可以识别到(在磁盘管理器可以查看), 无法弹出盘符 ## 解决 怀疑是 GPT 分区的原因, 然后排查了一下, 搜到这篇文章: [Windows 10无法识别Linux格式化的NTFS分区](https://zhuanlan.zhihu.com/p/651422085) 他说有可能是分区时选择了 兼容(Hybrid)GPT模式, 而非 纯净(protective)GPT模式 按照他的教程检查了一遍, 没有发现问题, 我的确实是纯净模式 然后发现他的分区类型跟我的不一样, 我的是: ``` 4202 Windows Storage Spaces ``` 而他的是 ``` 0700 Microsoft basic data ``` 然后就用 gdisk 里的 t 改变分区的类型, 把 NTFS 类型改为 0700, 结果问题就解决了

评论