Showing posts with label fdisk. Show all posts
Showing posts with label fdisk. Show all posts

24 October 2014

597. Missing partition -- gparted shows unallocated space

The issue:
I'm low on space on my / partition since ECCE has a way of putting really large files in /tmp. Rather than trying to fix the behaviour of ECCE, I'm planning on moving /tmp to a separate disk that's dedicated to highio processes and where ECCE can't cause my / to fill up. I might move /opt as well, to free even more space. The first step in such a move is to create an additional partition on your target disk and for that gparted is good as it can move all the data before creating the new partition.

Imagine my surprise when I fired up gparted and saw:

Using Disk Utilities (palimpsest) it doesn't look too odd:

Using fdisk I see a complete lack of partitions:
sudo fdisk /dev/sdb
Command (m for help): p Disk /dev/sdb: 1000 GB, 1000202273280 bytes 255 heads, 63 sectors/track, 121601 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System Command (m for help):

This may be a job for testdisk. I fired it up with sudo, selected Intel type partition, and kept selecting the defaults -- eventually my partition showed up. I then did a deep search to make sure everything was ok.






I then check using palimpsest and gparted:





(I also screwed up, then fixed a disk with a different issue -- but because I'm not really sure what I did to fix it I'll make a separate post about that at a later date. Maybe.)

12 November 2012

279. Formatting and adding a disk with fdisk

I've got a box with two harddrives -- sda (160 gb) has debian and sdb has CentOS (500 gb). I never use CentOS and I need the space for debian.

sudo fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors Units = sectors of 1 * 512 = 512 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/sda1 1 312581807 156290903+ ee GPT Disk /dev/sdb: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007e385 Device Boot Start End Blocks Id System /dev/sdb1 * 63 32772599 16386268+ 83 Linux /dev/sdb2 32772600 40965749 4096575 83 Linux /dev/sdb3 40965750 43006004 1020127+ 82 Linux swap / Solaris /dev/sdb4 43006005 976768064 466881030 5 Extended /dev/sdb5 43006068 976768064 466880998+ 83 Linux

We're in 'luck' since we're only interested in killing sdb, and gparted wants a Display (this is done remotely).
So
sudo fdisk /dev/sdb
Command (m for help): d Partition number (1-5): 1 Command (m for help): d Partition number (1-5): 2 Command (m for help): d Partition number (1-5): 3 Command (m for help): d Partition number (1-5): 4 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

So did it work?
 sudo fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted. Disk /dev/sda: 160.0 GB, 160041885696 bytes 255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors Units = sectors of 1 * 512 = 512 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/sda1 1 312581807 156290903+ ee GPT Disk /dev/sdb: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007e385 Device Boot Start End Blocks Id System
Time to create a new partition
sudo fdisk /dev/sdb
Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): Using default value 1 First sector (2048-976773167, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-976773167, default 976773167): Using default value 976773167 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

Did it work?
sudo fdisk -l /dev/sdb
Disk /dev/sdb: 500.1 GB, 500107862016 bytes 81 heads, 63 sectors/track, 191411 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0007e385 Device Boot Start End Blocks Id System /dev/sdb1 2048 976773167 488385560 83 Linux
Create a file system:
sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.5 (29-Jul-2012) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 30531584 inodes, 122096390 blocks 6104819 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 3727 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, 20480000, 23887872, 71663616, 78675968, 102400000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Let's automount it:
mkdir /home/me/scratch

and edit /etc/fstab
/dev/sdb1  /home/me/scratch    ext4    defaults        0       2

You're done.