The joy that is SysRq

I’m constantly surprised when I come across long-time Linux users who don’t know about SysRq. The Linux Magic System Request Key Hacks are a magic set of commands that you can get the Linux kernel to follow no matter what’s going on (unless it has panicked or totally deadlocked).

Why is this useful? Well, there are many situations where you can’t shut a system down properly, but you need to reboot. Examples:

  • You’ve had a kernel OOPS, which is not quite a panic but there could be memory corruption in the kernel, things are getting pretty weird, and quite honestly you don’t want to be running in that condition for any longer than necessary.
  • You have reason to believe it won’t be able to shut down properly.
  • Your system is almost-locked-up (i.e. the above point)
  • Your UPS has about 10 seconds worth of power left
  • Something is on fire (lp0 possibly?)
  • …Insert other esoteric failure modes here…

In any of those situations, grab a console keyboard, and type Alt+SysRq+s (sync), Alt+SysRq+u (unmount), wait for it to have synced, and finally Alt+SysRq+b (reboot NOW!). If you don’t have a handy keyboard attached to said machine, or are on another continent, you can

# echo u > /proc/sysrq-trigger

In my books, the useful SysRq commands are:

b
Reboot
f
Call the oom_killer
h
Display SysRq help
l
Print a kernel stacktrace
o
Power Off
r
Set your keyboard to RAW mode (required after some X breakages)
s
Sync all filesystems
u
Remount all filesystems read-only
0-9
Change console logging level

In fact, read the rest of the SysRq documentation, print it out, and tape it above your bed. Next time you reach for the reset switch on a Linux box, stop your self, type the S,U,B sequence, and watch your system come up as if nothing untoward has happened.

Update: I previously recommended U,S,B but after a bit of digging, I think S,U,B may be correct.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Raising Elephants

You can actually do a bit better by pressing Alt+SysRq+e, which sends SIGTERM to all processes. Processes which are still working can still terminate gracefully instead of being killed. There is a mnemonic to help remember the sequence.

There's a lot sewa bus

There's a lot sewa bus pariwisata to be desain interior rumah minimalis said about kebaya pengantin modern the way desain rumah minimalis the perfect rumah dijual combination of a info lokasi tempat obyek wisata movie and its music model rumah minimalis can move us

I must say that your blogpost

I must say that your blogpost was the most enjoying read I've seen in a long time. Greetings from gadgetterbaru and motorola moto g indonesia..

hello

Most people have no concept of how an automatic transmission works, yet they know how to drive a car. You don't have to study physics to understand the laws of motion to drive a car. You don't have to understand any of this stuff to use Macintosh.
Abstract wallpapers

fire rated downlights There

fire rated downlights There has been a mixed reaction from the electorate to the MDC-T’s withdrawal of its electoral challenge from the constitutional court.

kulaklık You have done a

kulaklık You have done a great job. I will definitely dig it and personally recommend to my friends. I am confident they will be benefited from this site.

buy computer game downloads

buy computer game downloads for pc I am commenting to let you know what a terrific experience my daughter enjoyed reading through your web page. She noticed a wide variety of pieces, with the inclusion of what it is like to have an awesome helping style to have the rest without hassle grasp some grueling matters

Perhaps you have tried

Perhaps you have tried complementing up any hockey player individuals time, with all the NHL person of 20 or perhaps 30 years back? Just considering the direction they are created tells the particular story regarding how crucial off-ice training is now for the particular performance regarding hockey participants. ice-hockey

Toko Obat Herbal Grosir

Toko Obat Herbal Grosir Amazon Plus menyediakan minuman alamiah berkualitas dengan maksud untuk membantu meningkatkan mutu kesehatan pribadi Anda. Kami merupakan toko online grosir produk obat herbal terpercaya di tanah air.
Ditangani oleh pekerja yang cekatan, sehingga menghadirkan mutu pelayanan Berdedikasi tinggi.
Jus Amazon Plus Herbal

Jus Amazon Plus adalah minuman kesehatan senyawa zaitun hydroxytyrosol satu-satunya di dunia.
Amazon Plus Herbal dalam bentuk jus yang berbahan dasar buah tropical alami dari seluruh pelosok dunia.
Salah satunya buah dari pedalaman Hutan Amazon, di amerika latin yang digabung dengan manggis, queen of fruit asal Indonesia yang juga terkandung kandungan antioksidan tinggi, juga dipadukan dengan zaitun yang kaya akan Hydroxytyrosol.

The more passion works and

The more passion works and ideas will powerfully helps your new adjusting area to provide an excellent terms with proper cut of identity. wedding photography

Best Mac Pc Computer Repair Services North Palm Beach

I cherish the online journal. Extraordinary post. It is genuine, individuals must figure out how to learn before they can learn. lol i know it sounds entertaining however it genuine. . . Best Mac Pc Computer Repair Services North Palm Beach

Exuviance

I have read some good stuff here. Certainly price bookmarking for revisiting. I surprise how much attempt you place to make any such fantastic informative website. Exuviance

We supply a range of

We supply a range of freestanding baths that are available in different shapes, sizes and colours and are all supplied by top-flight manufacturer's for your peace of mind. car insurance quote

great post

Cool stuff you have got and you keep redesign every one of us Tinnitus Miracle. I've been investigating for a little for any amazing articles or blog entries on this kind of zone. Tinnitus Miracle Reviews 2014

I always thought it was

I always thought it was supposed to be S,U,B?

re: S, U, B

You want to sync() the unmounted filesystem. If you sync it before it's unmounted, then the version on disk isn't guaranteed to be consistent.

S,U,B

Surely though if you wanted to sync data, you'd have to be able to write to the disk?

Yep, that's the way I know

Yep, that's the way I know it. You can't sync to an unmounted disk, as far as I'm aware. Once it's unmounted, it's totally unusable. You have to sync first. REISUB.

The only cases where I ever think of needing this, it turns out I can't use them anyway because it's panicked.

Recently I came across your

Recently I came across your blog and read along. I thought I would leave my first comment. I do not know what to say except that I liked reading. Nice blog. alliance home warranty
extended home warranty

Thank you for posting such a

Thank you for posting such a great article! I found your website perfect for my needs. It contains wonderful and helpful posts. Keep up the good work!
Scottsdale Electrician

Insured Profits So fortunes

Insured Profits
So fortunes to run over your incredible online journal. Your online journal presents to me a lot of fun.. Good fortunes with the site.

informative article

These kinds’ rentals are commonly proudly located at features who definitely are accented through fine-looking shores selling crystal-clear waters, contingency the Pacific Ocean. Hotels packages you completed a few fine points there. Thank Fat Loss Factor. Fat Loss Factor book

The primary a few months of

The primary a few months of my site there were no remarks; simply provide for it time; now they come in like insane consistently! Much obliged.
https://www.rebelmouse.com/thegirlfriendactivationsystem/

Thanks for writing such a

Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing...
Ahwatukee Electrician

Actually I read it yesterday

Actually I read it yesterday but I had some thoughts about it and today I wanted to read it again because it is very well written.
Preveri ponudbo

Many of us stock around 75

Many of us stock around 75 doctor offices and scorching tubs via five in the nations primary manufacturers, which include Artesian Doctor offices, Bahama Doctor offices by Empire, Master Doctor offices, Nordic Scorching Tubs, Vita Doctor offices and bringing out the Eileen Phelps Signature distinctive line of swim doctor offices by Get better at. spas

Actually your experimental

Actually your experimental writing capacities has motivated me to begin my own particular Blogengine blog now. Truly the blogging is spreading its wings quickly. Your compose up is a fine illustration of it.
Hotmail Support

S, U vs U, S

I knew about "Raising Skinny Elephants Is Utterly Boring" for quite a while, and it does S before U. So are all the other similar elephant mnemonics listed on the Wikipedia page.

Are you sure data can be synced to a read-only filesystem?

Greetings I discovered your

Greetings I discovered your site by oversight when i was hunting hurray down this acne issue, I must say your site is truly useful I additionally love the outline, its astonishing!.
Watch Movies Online

I just now cant stop reading

I just now cant stop reading this article. Its so cool, so rich in information we just didnt know. buy bitcoin and litecoin

across

I come across long-time Linux users who don’t know about SysRq. Cool cufflinks

REISUB

I've been a devotee of the R-E-I-S-U-B sequence for some time now, but it seems I'll have to change it to the less-pronounceable REIUSB. Amusingly some videos, when played in vlc, consistently cause my system to lock up so badly that the whole sequence goes unheeded.

break

Your UPS has about 10 seconds worth of power left Wedding Cufflinks

Looks like I could be wrong here

I need to do some research on this. From my understanding of the sync() call, it syncs all write-cached data, not necessarily filesystems.
I guess I need to dig deeper / do some testing...

Research

I’ve been digging into the kernel (thanks Linux Cross Reference). While I’m a kernel newbie, and don’t know much about the structures Linux uses for this, it looks to me like you should sync first, yes.

emergency_remount() calls fsync_super(), which calls sync_inodes_sb(), which looks like it may sync the file-system.

However, emergency_sync() calls sync_filesystems() which won’t work if they’ve been remounted RO (it checks).

I’m not a kernel developer.

stunning, incredible, I was

stunning, incredible, I was wondering how to cure skin inflammation regularly. furthermore discovered your site by google, took in a ton, now i'm a bit clear. I've bookmark your site furthermore include rss. keep us overhauled...
alcohol vaporizer

Sync

According to sysrq.txt,

's' - Will attempt to sync all mounted filesystems.

which means that it doesn't do anything for unmounted filesystems. Also from sysrq.txt: "I generally 'S'ync, 'U'mount, then re'B'oot when my system locks." I would guess that remounting a filesystem read-only includes syncing everything to disk.

This is a superb post I seen

This is a superb post I seen because of offer it. It is truly what I needed to see trust in future you will proceed for imparting such a magnificent post.
cheap mattresses stores calgary

stunning, incredible, I was

stunning, incredible, I was wondering how to cure skin inflammation regularly. furthermore discovered your site by google, took in a ton, now i'm a bit clear. I've bookmark your site furthermore include rss. keep us overhauled...
http://economie-automobile.hautetfort.com/

I concur with you. This post

I concur with you. This post is positively rousing. I like your post and all that you impart to us is present and exceptionally useful, I need to bookmark the page so I can return here from you that you have made an awesome showing .. - See more at:
sbi po recruitment

I possess decipher total the

I possess decipher total the statements plus advices posted by the guests for this column are truly propitious.Pikavippi

Took personal time to peruse

Took personal time to peruse all the remarks, yet I truly reveled in the article. It turned out to be Very useful to me and I am certain to all the commentators here! It's generally decent when you can be educated, as well as entertained!
brazilian virgin hair

his is my first time i visit

his is my first time i visit here. I discovered such a variety of engrossing stuff in your site, particularly its exchange. From the huge amounts of remarks on your articles, I figure I am by all account not the only one having all the relaxation here! Keep up the astounding work.
success

So luck to come across your

So luck to come across your excellent blog. Your blog brings me a great deal of fun.. Good luck with the site.
צלם לחתונה

Great post full of useful

Great post full of useful tips! My site is fairly new and I am also having a hard time getting my readers to leave comments. Analytics shows they are coming to the site but I have a feeling “nobody wants to be first Find Out More

U

Please note that 'u' doesn't actually unmount any filesystems, it just remounts them R/O. That said, it certainly seems like an emergency_sync() after emergency_remount() is useless; it might also be useless before-hand, but at least it'll actually do something that way.

Nice share of information

Nice share of information here. I really find this information really helpful for me. Thanks a lot, dude, for putting up this vital information on the internet for everybody to use.
cheap lambo doors

In my network connections

In my network connections dialogue I've got "ifupdown (wlan0)" under the wired tab - telling this set up is specific for wired connections https://www.rebelmouse.com/

I was extremely satisfied to

I was extremely satisfied to discover this site.i needed to thank you for this extraordinary read!! I doubtlessly getting a charge out of every last bit of it and I have you bookmarked to look at new stuff you post.
beverly hills limousine service

Took personal time to peruse

Took personal time to peruse all the remarks, yet I truly reveled in the article. It ended up being Very useful to me and I am certain to all the commentators here! It's generally pleasant when you can be educated, as well as entertained!
best exercises to make you jump higher

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.