Learn to share

Delete/remake Journal: Tune2fs

| Comments

In a case, where you want to delete the journal and then remake the journal below is a two step process:

1) Process to delete the journal

1
tune2fs -O ^has_journal /dev/sdx1

2) Remake the journal

1
tune2fs -O has_journal /dev/sdx1

Recover Partition Table: CoreOS

| Comments

This is a firedrill post on how to recover partition table, if partition table was accidently deleted.

I have a CoreOS VM deployed in Azure. I manually deleted all partitions from the disk, as you notice from below output

1
Number  Start (sector)    End (sector)  Size       Code  Name

Don’t panic! This is not my production server.

Before we start recovering the partition table, let’s backup the MBR code

1
dd if=/dev/sda of=mbr.bin bs=446 count=1

To find the lost partitions, there is testdisk tool developed by Christophe Grenier. So, I have copied the package to the server and then extracted the files.

1
2
3
4
5
6
7
8
9
coreos-test2 testdisk-7.0 # tar xvf testdisk-7.0.linux26-x86_64.tar.bz2

coreos-test2 testdisk-7.0 # cd testdisk-7.0

coreos-test2 testdisk-7.0 # ls
AUTHORS     COPYING    INFO  README  VERSION             fidentify.8       icons  l           photorec_static  readme.txt  testdisk_static
Android.mk  ChangeLog  NEWS  THANKS  documentation.html  fidentify_static  jni    photorec.8  qphotorec.8      testdisk.8

coreos-test2 testdisk-7.0 # ./testdisk_static /dev/sda

After that, I ran testdisk command on /dev/sda and you will notice a screen similar to below screenshot

images

After clicking proceed, I choosed EFI GPT partition map (because I knew on my CoreOS VM it has GPT with hybrid MBR), then Analyse, then Quick Search, and it found partitions.

Looking at the partition table, there are some missing partitions. I took a copy of the found partition table and then added the partitions manually then pressed Enter to continue and then write out the partition table.

For CoreOS specific, we need to additionally

-> fix type codes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
gdisk /dev/sda
  t
  1 
  EF00 (EFI System Partition)

  t
  2
  EF02 (BIOS Boot Partition)

  t
  3
  5DFBF5F4-2848-4BAC-AA5E-0D9A20B745A6 (Unknown / CoreOS Root)
  
  t
  4
  5DFBF5F4-2848-4BAC-AA5E-0D9A20B745A6 (Unknown / CoreOS Root)

  t
  5
  8300 (Linux Data)
  
  t
  6
  C95DC21A-DF0E-4340-8D7B-26CBFA9A03E0 (Unknown / CoreOS Reserved)
  
  t
  7
  3884DD41-8582-4404-B9A8-E9B84F2DF50E (Unknown / CoreOS undocumented/real root)
  
  
  p
  
  verify type codes for partitions: EF00, EF02, FFFF, FFFF, 8300, FFFF, FFFF

-> name the partitions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
c
  1
  EFI-SYSTEM
  
  c
  2
  BIOS-BOOT

  c
  3
  USR-A
  
  c
  4
  USR-B
  
  c
  5
  OEM
      
  c
  6
  OEM-CONFIG

  c
  7
  ROOT

-> number the partitions

1
2
3
4
5
6
7
8
9
10
11
12
x
  t
  7
  9

  t
  6
  7

  t
  5
  6

-> change it to hybrid MBR

1
2
3
4
5
6
7
8
9
r
  h
  1
  N
  0C
  Y
  N
  w
  Y

-> set the required attributes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
gdisk /dev/sda
        
  x
  a
  1
  2
  Enter
  a
  3
  48
  56
  Enter
  w
  Y

-> update the UUID of disk /dev/sda3

1
2
3
4
5
6
7
fdisk /dev/sda
        x
        u
        3
        7130C94A-213A-4E5A-8E26-6CCE9662F132 
        r
  w

Now, we are ready to restore the backed up MBR

1
dd if=mbr.bin of=/dev/sda

Finally, we have our lost partition table (~!~). I rebooted the server and ensured server is indeed booting successfully.

Linux QA: 101

| Comments

1
unable to handle kernel paging request at ffff8803980dcc70

Before, you read can you guess what above kernel message say? Above line suggests, kernel code tried to read some memory that isn’t loaded into RAM, which resulted in a page fault.

1
What does a superblock error mean?

In general, superblock errors would indicate some data corruption in the sector. It can either be due to faulty hardware or power failures.

1
Do we need fragmentation for ext filesystems?

ext filesystems are pretty fragmentation resistant and defragging isn’t really needed except in few cases like transferring large files while the disk was nearly full.

1
What is the equivalent command for chkdsk in Linux world?

fsck (easy to remember ;))

1
How to set immutable attribute to a file?

chattr +i filename

1
Which command displays whether the file has immutable attribute or not?

lsattr

1
Explain what /sbin/udevadm control --reload-rules command do?

Command reloads the rules from disk, and they will then apply to any new device that is added after that.

1
How to verify the semaphores limits?

ipcs -sul